View | Details | Raw Unified | Return to bug 43502
Collapse All | Expand All

(-)modules/loggers/mod_log_config.c.logconfigtest (+54 lines)
Lines 1496-1501 Link Here
1496
1496
1497
    return OK;
1497
    return OK;
1498
}
1498
}
1499
static void log_configtest(apr_pool_t *p, server_rec *s)
1500
{
1501
    apr_status_t rc;
1502
    /* We check if we can at least open the error file.
1503
    */ 
1504
    if ((rc = apr_file_open(&s->error_log, s->error_fname, APR_APPEND | APR_WRITE | APR_CREATE | APR_LARGEFILE,
1505
                    APR_OS_DEFAULT, p)) != APR_SUCCESS) {
1506
        ap_log_error(APLOG_MARK, APLOG_STARTUP, rc, NULL,
1507
            "Could not open error log file %s.",s->error_fname);
1508
    } else {
1509
        apr_file_close(s->error_log);
1510
    }
1511
    /* We check if we can open the other files
1512
    */
1513
    multi_log_state *mls = ap_get_module_config(s->module_config, &log_config_module);
1514
    config_log_state *clsarray;
1515
    int i;
1516
1517
    /*
1518
     * Log this transaction..
1519
     */
1520
    if (mls->config_logs->nelts) {
1521
        clsarray = (config_log_state *) mls->config_logs->elts;
1522
        for (i = 0; i < mls->config_logs->nelts; ++i) {
1523
            config_log_state *cls = &clsarray[i];
1524
            const char *fname = cls->fname;
1525
            apr_file_t *logfile = NULL;
1526
            if ((rc = apr_file_open(&logfile, fname, APR_APPEND | APR_WRITE | APR_CREATE | APR_LARGEFILE,
1527
                            APR_OS_DEFAULT, p)) != APR_SUCCESS) {
1528
                ap_log_error(APLOG_MARK, APLOG_STARTUP, rc, NULL,
1529
                    "Could not open log file %s.",fname);
1530
            } else {
1531
                apr_file_close(logfile);
1532
            }
1533
        }
1534
    }
1535
    else if (mls->server_config_logs) {
1536
        clsarray = (config_log_state *) mls->server_config_logs->elts;
1537
        for (i = 0; i < mls->server_config_logs->nelts; ++i) {
1538
            config_log_state *cls = &clsarray[i];
1539
            const char *fname = cls->fname;
1540
            apr_file_t *logfile = NULL;
1541
            if ((rc = apr_file_open(&logfile, fname, APR_APPEND | APR_WRITE | APR_CREATE | APR_LARGEFILE,
1542
                            APR_OS_DEFAULT, p)) != APR_SUCCESS) {
1543
                ap_log_error(APLOG_MARK, APLOG_STARTUP, rc, NULL,
1544
                    "Could not open log file %s.",fname);
1545
            } else {
1546
                apr_file_close(logfile);
1547
            }
1548
        }
1549
    }
1550
1551
}
1499
1552
1500
static void register_hooks(apr_pool_t *p)
1553
static void register_hooks(apr_pool_t *p)
1501
{
1554
{
Lines 1503-1508 Link Here
1503
    ap_hook_child_init(init_child,NULL,NULL,APR_HOOK_MIDDLE);
1556
    ap_hook_child_init(init_child,NULL,NULL,APR_HOOK_MIDDLE);
1504
    ap_hook_open_logs(init_config_log,NULL,NULL,APR_HOOK_MIDDLE);
1557
    ap_hook_open_logs(init_config_log,NULL,NULL,APR_HOOK_MIDDLE);
1505
    ap_hook_log_transaction(multi_log_transaction,NULL,NULL,APR_HOOK_MIDDLE);
1558
    ap_hook_log_transaction(multi_log_transaction,NULL,NULL,APR_HOOK_MIDDLE);
1559
    ap_hook_test_config(log_configtest,NULL,NULL,APR_HOOK_MIDDLE);
1506
1560
1507
    /* Init log_hash before we register the optional function. It is
1561
    /* Init log_hash before we register the optional function. It is
1508
     * possible for the optional function, ap_register_log_handler,
1562
     * possible for the optional function, ap_register_log_handler,

Return to bug 43502