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

(-)modules/loggers/mod_log_config.c.logconfigtest (+72 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
    /* Iterate through all the virtual hosts
1502
    */
1503
    apr_status_t rc;
1504
    const char *fname;
1505
    const char *config_fname;
1506
    apr_file_t *logfile;
1507
    while (s) {
1508
        /* We check if we can at least open the error file.
1509
        */
1510
        if (s->defn_name) {
1511
            config_fname = s->defn_name;
1512
        } else {
1513
            config_fname = "main config file";
1514
        }
1515
        if (s->error_fname) {
1516
            fname = ap_server_root_relative(p, s->error_fname);
1517
            logfile = NULL;
1518
            if ((rc = apr_file_open(&logfile, fname, APR_APPEND | APR_WRITE | APR_CREATE | APR_LARGEFILE,
1519
                            APR_OS_DEFAULT, p)) != APR_SUCCESS) {
1520
                ap_log_error(APLOG_MARK, APLOG_STARTUP, rc, NULL,
1521
                    "Could not open error log file %s for server defined in %s.",fname,config_fname);
1522
            } else {
1523
                apr_file_close(logfile);
1524
            }
1525
        }
1526
        /* We check if we can open the other files
1527
        */
1528
        multi_log_state *mls = ap_get_module_config(s->module_config, &log_config_module);
1529
        config_log_state *clsarray;
1530
        int i;
1531
1532
        /*
1533
         * Log this transaction..
1534
         */
1535
        if (mls->config_logs->nelts) {
1536
            clsarray = (config_log_state *) mls->config_logs->elts;
1537
            for (i = 0; i < mls->config_logs->nelts; ++i) {
1538
                config_log_state *cls = &clsarray[i];
1539
                if (*(cls->fname) == '|') continue; /* don't handle piped logs */
1540
                fname = ap_server_root_relative(p, cls->fname);
1541
                logfile = NULL;
1542
                if ((rc = apr_file_open(&logfile, fname, APR_APPEND | APR_WRITE | APR_CREATE | APR_LARGEFILE,
1543
                                APR_OS_DEFAULT, p)) != APR_SUCCESS) {
1544
                    ap_log_error(APLOG_MARK, APLOG_STARTUP, rc, NULL,
1545
                        "Could not open log file %s for server defined in %s.",fname,config_fname);
1546
                } else {
1547
                    apr_file_close(logfile);
1548
                }
1549
            }
1550
        }
1551
        else if (mls->server_config_logs) {
1552
            clsarray = (config_log_state *) mls->server_config_logs->elts;
1553
            for (i = 0; i < mls->server_config_logs->nelts; ++i) {
1554
                config_log_state *cls = &clsarray[i];
1555
                if (*(cls->fname) == '|') continue; /* don't handle piped logs */
1556
                fname = ap_server_root_relative(p, cls->fname);
1557
                logfile = NULL;
1558
                if ((rc = apr_file_open(&logfile, fname, APR_APPEND | APR_WRITE | APR_CREATE | APR_LARGEFILE,
1559
                                APR_OS_DEFAULT, p)) != APR_SUCCESS) {
1560
                    ap_log_error(APLOG_MARK, APLOG_STARTUP, rc, NULL,
1561
                        "Could not open log file %s for server defined in %s.",fname,config_fname);
1562
                } else {
1563
                    apr_file_close(logfile);
1564
                }
1565
            }
1566
        }
1567
        s = s->next;
1568
    }
1569
}
1499
1570
1500
static void register_hooks(apr_pool_t *p)
1571
static void register_hooks(apr_pool_t *p)
1501
{
1572
{
Lines 1503-1508 Link Here
1503
    ap_hook_child_init(init_child,NULL,NULL,APR_HOOK_MIDDLE);
1574
    ap_hook_child_init(init_child,NULL,NULL,APR_HOOK_MIDDLE);
1504
    ap_hook_open_logs(init_config_log,NULL,NULL,APR_HOOK_MIDDLE);
1575
    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);
1576
    ap_hook_log_transaction(multi_log_transaction,NULL,NULL,APR_HOOK_MIDDLE);
1577
    ap_hook_test_config(log_configtest,NULL,NULL,APR_HOOK_MIDDLE);
1506
1578
1507
    /* Init log_hash before we register the optional function. It is
1579
    /* Init log_hash before we register the optional function. It is
1508
     * possible for the optional function, ap_register_log_handler,
1580
     * possible for the optional function, ap_register_log_handler,

Return to bug 43502