]> granicus.if.org Git - apache/commitdiff
First step in removing the fprintf(stderr problem from Apache. Basically,
authorRyan Bloom <rbb@apache.org>
Thu, 18 Nov 1999 23:07:53 +0000 (23:07 +0000)
committerRyan Bloom <rbb@apache.org>
Thu, 18 Nov 1999 23:07:53 +0000 (23:07 +0000)
I defined APLOG_STARTUP, which refrains from printing the date string
and the log level information in log_error_core.  I then changed all the
fprintf(stderr calls to ap_log_error, and used APLOG_STARTUP.
log_error_core on Unix takes care of creating a log file and directing
it to stderr if a log file isn't already active.  I will continue to
make these changes tomorrow.  Currently, the main code and the dexter
mpm have been modified.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@84134 13f79535-47bb-0310-9956-ffa450edef68

include/http_log.h
modules/http/http_core.c
server/config.c
server/log.c
server/main.c
server/mpm/dexter/dexter.c
server/mpm/dexter/scoreboard.c
server/util.c

index 88d4c1bafe351f4241019fca8bcbf768164bef5a..da7b1555e2b7e537f879a6fbd6c055dd9da11e6d 100644 (file)
@@ -98,6 +98,9 @@ extern "C" {
 #define APLOG_WIN32ERROR       ((APLOG_LEVELMASK+1) * 2)
 #endif
 
+/* normal but significant condition on startup, usually printed to stderr */
+#define APLOG_STARTUP           ((APLOG_LEVELMASK + 1) * 4) 
+
 #ifndef DEFAULT_LOGLEVEL
 #define DEFAULT_LOGLEVEL       APLOG_WARNING
 #endif
index 488169a4578ad2b5526400e00bb812a42f5208b4..ccf6d38c81e473ba84630c153509813c0713611f 100644 (file)
@@ -1012,8 +1012,9 @@ static const char *set_document_root(cmd_parms *cmd, void *dummy, char *arg)
     arg = ap_os_canonical_filename(cmd->pool, arg);
     if (/* TODO: ap_configtestonly && ap_docrootcheck && */ !ap_is_directory(arg)) {
        if (cmd->server->is_virtual) {
-           fprintf(stderr, "Warning: DocumentRoot [%s] does not exist\n",
-                   arg);
+           ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
+                         "Warning: DocumentRoot [%s] does not exist",
+                        arg);
        }
        else {
            return "DocumentRoot must be a directory";
index 7e102b149445b3595c0a1c65d823868dd0ac9feb..3f81cdcc45e79c46c84a7c746d4ed462b6f2456f 100644 (file)
@@ -385,9 +385,10 @@ API_EXPORT(void) ap_add_module(module *m)
      */
 
     if (m->version != MODULE_MAGIC_NUMBER_MAJOR) {
-       fprintf(stderr, "%s: module \"%s\" is not compatible with this "
-               "version of Apache.\n", ap_server_argv0, m->name);
-       fprintf(stderr, "Please contact the vendor for the correct version.\n");
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
+                     "%s: module \"%s\" is not compatible with this "
+                    "version of Apache.", ap_server_argv0, m->name);
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "Please contact the vendor for the correct version.");
        exit(1);
     }
 
@@ -400,10 +401,12 @@ API_EXPORT(void) ap_add_module(module *m)
        dynamic_modules++;
 
        if (dynamic_modules > DYNAMIC_MODULE_LIMIT) {
-           fprintf(stderr, "%s: module \"%s\" could not be loaded, because"
-                   " the dynamic\n", ap_server_argv0, m->name);
-           fprintf(stderr, "module limit was reached. Please increase "
-                   "DYNAMIC_MODULE_LIMIT and recompile.\n");
+           ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
+                         "%s: module \"%s\" could not be loaded, because"
+                        " the dynamic", ap_server_argv0, m->name);
+           ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
+                         "module limit was reached. Please increase "
+                        "DYNAMIC_MODULE_LIMIT and recompile.");
            exit(1);
        }
     }
@@ -544,7 +547,8 @@ void ap_setup_prelinked_modules(process_rec *process)
     ap_loaded_modules = (module **)ap_palloc(process->pool,
         sizeof(module *)*(total_modules+DYNAMIC_MODULE_LIMIT+1));
     if (ap_loaded_modules == NULL) {
-       fprintf(stderr, "Ouch!  Out of memory in ap_setup_prelinked_modules()!\n");
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
+                     "Ouch!  Out of memory in ap_setup_prelinked_modules()!");
     }
     for (m = ap_preloaded_modules, m2 = ap_loaded_modules; *m != NULL; )
         *m2++ = *m++;
@@ -1004,7 +1008,8 @@ static void process_command_config(server_rec *s, ap_array_header_t *arr, ap_con
     errmsg = ap_srm_command_loop(&parms, s->lookup_defaults);
 
     if (errmsg) {
-        fprintf(stderr, "Syntax error in -C/-c directive:\n%s\n", errmsg);
+        ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
+                     "Syntax error in -C/-c directive:\n%s", errmsg);
         exit(1);
     }
 
@@ -1041,17 +1046,20 @@ void ap_process_resource_config(server_rec *s, const char *fname, ap_context_t *
     parms.override = (RSRC_CONF | OR_ALL) & ~(OR_AUTHCFG | OR_LIMIT);
 
     if (ap_pcfg_openfile(&parms.config_file, p, fname) != APR_SUCCESS) {
-       fprintf(stderr, "%s: could not open document config file %s\n",
-               ap_server_argv0, fname);
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
+                     "%s: could not open document config file %s",
+                    ap_server_argv0, fname);
        exit(1);
     }
 
     errmsg = ap_srm_command_loop(&parms, s->lookup_defaults);
 
     if (errmsg) {
-       fprintf(stderr, "Syntax error on line %d of %s:\n",
-               parms.config_file->line_number, parms.config_file->name);
-       fprintf(stderr, "%s\n", errmsg);
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
+                     "Syntax error on line %d of %s:",
+                    parms.config_file->line_number, parms.config_file->name);
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
+                     "%s", errmsg);
        exit(1);
     }
 
@@ -1149,7 +1157,8 @@ CORE_EXPORT(const char *) ap_init_virtual_host(ap_context_t *p, const char *host
        limits.rlim_cur += 2;
        if (setrlimit(RLIMIT_NOFILE, &limits) < 0) {
            perror("setrlimit(RLIMIT_NOFILE)");
-           fprintf(stderr, "Cannot exceed hard limit for open files");
+           ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
+                         "Cannot exceed hard limit for open files");
        }
     }
 #endif
index b0b006f715727638e0d22e40ce8d0b27ff8689ff..38959ef09988589ca4e45beb96c53cacabb81051 100644 (file)
@@ -229,8 +229,9 @@ static void open_error_log(server_rec *s, ap_context_t *p)
         rc = log_child (p, s->error_fname+1, NULL, &dummy, NULL);
         if (rc != APR_SUCCESS) {
            perror("ap_spawn_child");
-           fprintf(stderr, "Couldn't fork child for ErrorLog process\n");
-           exit(1);
+           ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
+                         "Couldn't fork child for ErrorLog process");
+                        exit(1);
        }
 
         s->error_log = dummy;
@@ -263,8 +264,9 @@ static void open_error_log(server_rec *s, ap_context_t *p)
         if (ap_open(&s->error_log, fname, APR_APPEND | 
                     APR_READ | APR_WRITE | APR_CREATE, APR_OS_DEFAULT, p) != APR_SUCCESS) {
             perror("fopen");
-            fprintf(stderr, "%s: could not open error log file %s.\n",
-                   ap_server_argv0, fname);
+            ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
+                         "%s: could not open error log file %s.",
+                        ap_server_argv0, fname);
             exit(1);
        }
     }
@@ -342,14 +344,18 @@ static void log_error_core(const char *file, int line, int level,
        if (((level & APLOG_LEVELMASK) != APLOG_NOTICE) &&
            ((level & APLOG_LEVELMASK) > DEFAULT_LOGLEVEL))
            return;
+#ifdef WIN32
+        /* This is where the different ap_put_os_file's belong */
+#else
        ap_put_os_file(&logf, &errfileno, NULL);
+#endif
     }
     else if (s->error_log) {
        /*
         * If we are doing normal logging, don't log messages that are
         * above the server log level unless it is a startup/shutdown notice
         */
-       if (((level & APLOG_LEVELMASK) != APLOG_NOTICE) &&
+       if (((level & APLOG_LEVELMASK) != APLOG_NOTICE) && 
            ((level & APLOG_LEVELMASK) > s->loglevel))
            return;
        logf = s->error_log;
@@ -376,15 +382,16 @@ static void log_error_core(const char *file, int line, int level,
        logf = NULL;
     }
 
-    if (logf) {
+    if (logf && ((level & APLOG_STARTUP) != APLOG_STARTUP)) {
        len = ap_snprintf(errstr, MAX_STRING_LEN, "[%s] ", ap_get_time());
     } else {
        len = 0;
     }
 
-    len += ap_snprintf(errstr + len, MAX_STRING_LEN - len,
-           "[%s] ", priorities[level & APLOG_LEVELMASK].t_name);
-
+    if ((level & APLOG_STARTUP) != APLOG_STARTUP) {
+        len += ap_snprintf(errstr + len, MAX_STRING_LEN - len,
+               "[%s] ", priorities[level & APLOG_LEVELMASK].t_name);
+    }
 #ifndef TPF
     if (file && (level & APLOG_LEVELMASK) == APLOG_DEBUG) {
 #ifdef _OSD_POSIX
@@ -557,8 +564,9 @@ void ap_log_pid(ap_context_t *p, const char *fname)
 
     if(ap_open(&pid_file, fname, APR_WRITE | APR_CREATE, APR_OS_DEFAULT, p) != APR_SUCCESS) {
        perror("fopen");
-        fprintf(stderr, "%s: could not log pid to file %s\n",
-               ap_server_argv0, fname);
+        ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
+                     "%s: could not log pid to file %s",
+                    ap_server_argv0, fname);
         exit(1);
     }
     ap_fprintf(pid_file, "%ld\n", (long)mypid);
@@ -597,9 +605,9 @@ API_EXPORT(void) ap_log_reason(const char *reason, const char *file, request_rec
 
 API_EXPORT(void) ap_log_assert(const char *szExp, const char *szFile, int nLine)
 {
-  /* Use AP funcs to output message and abort program.  */
-    fprintf(stderr, "[%s] file %s, line %d, assertion \"%s\" failed\n",
-           ap_get_time(), szFile, nLine, szExp);
+    ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
+                 "[%s] file %s, line %d, assertion \"%s\" failed",
+                ap_get_time(), szFile, nLine, szExp);
 #ifndef WIN32
     /* unix assert does an abort leading to a core dump */
     abort();
@@ -633,8 +641,8 @@ static int piped_log_spawn(piped_log *pl)
         (ap_setprocattr_dir(procattr, pl->program)        != APR_SUCCESS) ||
         (ap_set_childin(procattr, pl->fds[0], pl->fds[1]) != APR_SUCCESS)) {
         /* Something bad happened, give up and go away. */
-       fprintf(stderr,
-           "piped_log_spawn: unable to exec %s -c '%s': %s\n",
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
+           "piped_log_spawn: unable to exec %s -c '%s': %s",
            SHELL_PATH, pl->program, strerror (errno));
         rc = -1;
     }
@@ -672,8 +680,8 @@ static void piped_log_maintenance(int reason, void *data, ap_wait_t status)
        if (piped_log_spawn(pl) != APR_SUCCESS) {
            /* what can we do?  This could be the error log we're having
             * problems opening up... */
-           fprintf(stderr,
-               "piped_log_maintenance: unable to respawn '%s': %s\n",
+           ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
+               "piped_log_maintenance: unable to respawn '%s': %s",
                pl->program, strerror(errno));
        }
        break;
@@ -760,7 +768,8 @@ API_EXPORT(piped_log *) ap_open_piped_log(ap_context_t *p, const char *program)
     rc = log_child(p, program, NULL, &dummy, NULL);
     if (rc != APR_SUCCESS) {
        perror("ap_spawn_child");
-       fprintf(stderr, "Couldn't fork child for piped log process\n");
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
+                     "Couldn't fork child for piped log process");
        exit (1);
     }
 
index 097af3bd96724466bf82adf86206190e4aa670ff..5df9d05202a3a70a48ba930f4c1c46352e4752c9 100644 (file)
@@ -58,6 +58,7 @@
 #define CORE_PRIVATE
 #include "httpd.h" 
 #include "http_main.h" 
+#include "http_log.h" 
 #include "http_config.h"
 #include "util_uri.h" 
 #include "ap_mpm.h"
@@ -229,30 +230,30 @@ static void usage(process_rec *process)
        pad[i] = ' ';
     pad[i] = '\0';
 #ifdef SHARED_CORE
-    fprintf(stderr, "Usage: %s [-R directory] [-D name] [-d directory] [-f file]\n", bin);
+    ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0,NULL , "Usage: %s [-R directory] [-D name] [-d directory] [-f file]", bin);
 #else
-    fprintf(stderr, "Usage: %s [-D name] [-d directory] [-f file]\n", bin);
+    ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "Usage: %s [-D name] [-d directory] [-f file]", bin);
 #endif
-    fprintf(stderr, "       %s [-C \"directive\"] [-c \"directive\"]\n", pad);
-    fprintf(stderr, "       %s [-v] [-V] [-h] [-l] [-L] [-S] [-t] [-T]\n", pad);
-    fprintf(stderr, "Options:\n");
+    ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "       %s [-C \"directive\"] [-c \"directive\"]", pad);
+    ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "       %s [-v] [-V] [-h] [-l] [-L] [-S] [-t] [-T]", pad);
+    ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "Options:");
 #ifdef SHARED_CORE
-    fprintf(stderr, "  -R directory     : specify an alternate location for shared object files\n");
-#endif
-    fprintf(stderr, "  -D name          : define a name for use in <IfDefine name> directives\n");
-    fprintf(stderr, "  -d directory     : specify an alternate initial ServerRoot\n");
-    fprintf(stderr, "  -f file          : specify an alternate ServerConfigFile\n");
-    fprintf(stderr, "  -C \"directive\"   : process directive before reading config files\n");
-    fprintf(stderr, "  -c \"directive\"   : process directive after  reading config files\n");
-    fprintf(stderr, "  -v               : show version number\n");
-    fprintf(stderr, "  -V               : show compile settings\n");
-    fprintf(stderr, "  -h               : list available command line options (this page)\n");
-    fprintf(stderr, "  -l               : list compiled in modules\n");
-    fprintf(stderr, "  -L               : list available configuration directives\n");
+    ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "  -R directory     : specify an alternate location for shared object files");
+#endif
+    ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "  -D name          : define a name for use in <IfDefine name> directives");
+    ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "  -d directory     : specify an alternate initial ServerRoot");
+    ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "  -f file          : specify an alternate ServerConfigFile");
+    ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "  -C \"directive\"   : process directive before reading config files");
+    ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "  -c \"directive\"   : process directive after  reading config files");
+    ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "  -v               : show version number");
+    ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "  -V               : show compile settings");
+    ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "  -h               : list available command line options (this page)");
+    ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "  -l               : list compiled in modules");
+    ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "  -L               : list available configuration directives");
     /* TODOC: -S has been replaced by '-t -D DUMP_VHOSTS' */
-    /* fprintf(stderr, "  -S               : show parsed settings (currently only vhost settings)\n"); */
-    fprintf(stderr, "  -t               : run syntax check for config files (with docroot check)\n");
-    fprintf(stderr, "  -T               : run syntax check for config files (without docroot check)\n");
+    /* ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "  -S               : show parsed settings (currently only vhost settings)"); */
+    ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "  -t               : run syntax check for config files (with docroot check)");
+    ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "  -T               : run syntax check for config files (without docroot check)");
     /* TODOC: -X goes away, expect MPMs to use -D options */
     destroy_and_exit_process(process, 1);
 }
@@ -348,7 +349,7 @@ API_EXPORT_NONSTD(int)        main(int argc, char *argv[])
     ap_run_pre_config(pconf, plog, ptemp);
     server_conf = ap_read_config(process, ptemp, confname);
     if (configtestonly) {
-       fprintf(stderr, "Syntax OK\n");
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "Syntax OK\n");
        destroy_and_exit_process(process, 0);
     }
     ap_clear_pool(plog);
index 0f7b24c8978af93a9bf5120316c7f21bc377ef39..16fc65a0138568fd596a74c2de96ae53fdf2f705 100644 (file)
@@ -1536,15 +1536,19 @@ static const char *set_num_daemons (cmd_parms *cmd, void *dummy, char *arg)
 
     num_daemons = atoi(arg);
     if (num_daemons > HARD_SERVER_LIMIT) {
-       fprintf(stderr, "WARNING: NumServers of %d exceeds compile time limit "
-           "of %d servers,\n", num_daemons, HARD_SERVER_LIMIT);
-       fprintf(stderr, " lowering NumServers to %d.  To increase, please "
-           "see the\n", HARD_SERVER_LIMIT);
-       fprintf(stderr, " HARD_SERVER_LIMIT define in src/include/httpd.h.\n");
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
+                    "WARNING: NumServers of %d exceeds compile time limit "
+                    "of %d servers,", num_daemons, HARD_SERVER_LIMIT);
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
+                    " lowering NumServers to %d.  To increase, please "
+                    "see the", HARD_SERVER_LIMIT);
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
+                    " HARD_SERVER_LIMIT define in src/include/httpd.h.");
        num_daemons = HARD_SERVER_LIMIT;
     } 
     else if (num_daemons < 1) {
-       fprintf(stderr, "WARNING: Require NumServers > 0, setting to 1\n");
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
+                     "WARNING: Require NumServers > 0, setting to 1");
        num_daemons = 1;
     }
     return NULL;
@@ -1559,15 +1563,19 @@ static const char *set_threads_to_start (cmd_parms *cmd, void *dummy, char *arg)
 
     threads_to_start = atoi(arg);
     if (threads_to_start > HARD_THREAD_LIMIT) {
-        fprintf(stderr, "WARNING: StartThreads of %d exceeds compile time"
-                "limit of %d threads,\n", threads_to_start,
-                HARD_THREAD_LIMIT);
-        fprintf(stderr, " lowering StartThreads to %d. To increase, please"
-                "see the\n", HARD_THREAD_LIMIT);
-        fprintf(stderr, " HARD_THREAD_LIMIT define in src/include/httpd.h.\n");
+        ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
+                     "WARNING: StartThreads of %d exceeds compile time"
+                     "limit of %d threads,", threads_to_start,
+                     HARD_THREAD_LIMIT);
+        ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
+                     "lowering StartThreads to %d. To increase, please"
+                     "see the", HARD_THREAD_LIMIT);
+        ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
+                     "HARD_THREAD_LIMIT define in src/include/httpd.h.");
     }
     else if (threads_to_start < 1) {
-       fprintf(stderr, "WARNING: Require StartThreads > 0, setting to 1\n");
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
+                     "WARNING: Require StartThreads > 0, setting to 1");
        threads_to_start = 1;
     }
     return NULL;
@@ -1582,9 +1590,12 @@ static const char *set_min_spare_threads(cmd_parms *cmd, void *dummy, char *arg)
 
     min_spare_threads = atoi(arg);
     if (min_spare_threads <= 0) {
-       fprintf(stderr, "WARNING: detected MinSpareThreads set to non-positive.\n");
-       fprintf(stderr, "Resetting to 1 to avoid almost certain Apache failure.\n");
-       fprintf(stderr, "Please read the documentation.\n");
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
+                    "WARNING: detected MinSpareThreads set to non-positive.");
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
+                    "Resetting to 1 to avoid almost certain Apache failure.");
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
+                    "Please read the documentation.");
        min_spare_threads = 1;
     }
        
@@ -1600,8 +1611,10 @@ static const char *set_max_spare_threads(cmd_parms *cmd, void *dummy, char *arg)
 
     max_spare_threads = atoi(arg);
     if (max_spare_threads >= HARD_THREAD_LIMIT) {
-       fprintf(stderr, "WARNING: detected MinSpareThreads set higher than\n");
-       fprintf(stderr, "HARD_THREAD_LIMIT. Resetting to %d\n", HARD_THREAD_LIMIT);
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
+                    "WARNING: detected MinSpareThreads set higher than");
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
+                    "HARD_THREAD_LIMIT. Resetting to %d", HARD_THREAD_LIMIT);
        max_spare_threads = HARD_THREAD_LIMIT;
     }
     return NULL;
@@ -1616,8 +1629,10 @@ static const char *set_max_threads(cmd_parms *cmd, void *dummy, char *arg)
 
     max_threads = atoi(arg);
     if (max_threads > HARD_THREAD_LIMIT) {
-       fprintf(stderr, "WARNING: detected MaxThreadsPerChild set higher than\n");
-       fprintf(stderr, "HARD_THREAD_LIMIT. Resetting to %d\n", HARD_THREAD_LIMIT);
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
+                    "WARNING: detected MaxThreadsPerChild set higher than");
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
+                    "HARD_THREAD_LIMIT. Resetting to %d", HARD_THREAD_LIMIT);
        max_threads = HARD_THREAD_LIMIT;
     }
     return NULL;
index 1403d2502b602c9b6a6000be14bf8d9d9d8c4e46..8e75d79009c6bd6bedaadab959cf016934179c3a 100644 (file)
@@ -145,15 +145,16 @@ static void setup_shared_mem(ap_context_t *p)
 
     m = (caddr_t) create_shared_heap("\\SHAREMEM\\SCOREBOARD", SCOREBOARD_SIZE);
     if (m == 0) {
-       fprintf(stderr, "%s: Could not create OS/2 Shared memory pool.\n",
-               ap_server_argv0);
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
+                     "%s: Could not create OS/2 Shared memory pool.",
+                    ap_server_argv0);
        exit(APEXIT_INIT);
     }
 
     rc = _uopen((Heap_t) m);
     if (rc != 0) {
-       fprintf(stderr,
-               "%s: Could not uopen() newly created OS/2 Shared memory pool.\n",
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
+               "%s: Could not uopen() newly created OS/2 Shared memory pool.",
                ap_server_argv0);
     }
     ap_scoreboard_image = (scoreboard *) m;
@@ -166,7 +167,8 @@ API_EXPORT(void) reopen_scoreboard(ap_context_t *p)
 
     m = (caddr_t) get_shared_heap("\\SHAREMEM\\SCOREBOARD");
     if (m == 0) {
-       fprintf(stderr, "%s: Could not find existing OS/2 Shared memory pool.\n",
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
+                     "%s: Could not find existing OS/2 Shared memory pool.",
                ap_server_argv0);
        exit(APEXIT_INIT);
     }
@@ -280,14 +282,16 @@ static void setup_shared_mem(ap_context_t *p)
        int fd = mkstemp(mfile);
        if (fd == -1) {
            perror("open");
-           fprintf(stderr, "%s: Could not open %s\n", ap_server_argv0, mfile);
+           ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
+                         "%s: Could not open %s", ap_server_argv0, mfile);
            exit(APEXIT_INIT);
        }
        m = mmap((caddr_t) 0, SCOREBOARD_SIZE,
                PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
        if (m == (caddr_t) - 1) {
            perror("mmap");
-           fprintf(stderr, "%s: Could not mmap %s\n", ap_server_argv0, mfile);
+           ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
+                         "%s: Could not mmap %s", ap_server_argv0, mfile);
            exit(APEXIT_INIT);
        }
        close(fd);
@@ -299,7 +303,8 @@ static void setup_shared_mem(ap_context_t *p)
 #endif
     if (m == (caddr_t) - 1) {
        perror("mmap");
-       fprintf(stderr, "%s: Could not mmap memory\n", ap_server_argv0);
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
+                     "%s: Could not mmap memory", ap_server_argv0);
        exit(APEXIT_INIT);
     }
 #else
@@ -309,14 +314,16 @@ static void setup_shared_mem(ap_context_t *p)
     fd = open("/dev/zero", O_RDWR);
     if (fd == -1) {
        perror("open");
-       fprintf(stderr, "%s: Could not open /dev/zero\n", ap_server_argv0);
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
+                     "%s: Could not open /dev/zero", ap_server_argv0);
        exit(APEXIT_INIT);
     }
     m = mmap((caddr_t) 0, SCOREBOARD_SIZE,
             PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
     if (m == (caddr_t) - 1) {
        perror("mmap");
-       fprintf(stderr, "%s: Could not mmap /dev/zero\n", ap_server_argv0);
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
+                     "%s: Could not mmap /dev/zero", ap_server_argv0);
        exit(APEXIT_INIT);
     }
     close(fd);
index 379211ef2bee450030d8e5f4251517735fe2a021..8f797b1b406c08c052b59c053d0d58b7d180356a 100644 (file)
@@ -1706,7 +1706,7 @@ char *strdup(const char *str)
     char *sdup;
 
     if (!(sdup = (char *) malloc(strlen(str) + 1))) {
-       fprintf(stderr, "Ouch!  Out of memory in our strdup()!\n");
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "Ouch!  Out of memory in our strdup()!");
        return NULL;
     }
     sdup = strcpy(sdup, str);
@@ -1877,7 +1877,7 @@ API_EXPORT(uid_t) ap_uname2id(const char *name)
        return (atoi(&name[1]));
 
     if (!(ent = getpwnam(name))) {
-       fprintf(stderr, "%s: bad user name %s\n", ap_server_argv0, name);
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "%s: bad user name %s", ap_server_argv0, name);
        exit(1);
     }
     return (ent->pw_uid);
@@ -1895,7 +1895,7 @@ API_EXPORT(gid_t) ap_gname2id(const char *name)
        return (atoi(&name[1]));
 
     if (!(ent = getgrnam(name))) {
-       fprintf(stderr, "%s: bad group name %s\n", ap_server_argv0, name);
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "%s: bad group name %s", ap_server_argv0, name);
        exit(1);
     }
     return (ent->gr_gid);
@@ -1938,14 +1938,14 @@ unsigned long ap_get_virthost_addr(char *w, unsigned short *ports)
     hep = gethostbyname(w);
 
     if ((!hep) || (hep->h_addrtype != AF_INET || !hep->h_addr_list[0])) {
-       fprintf(stderr, "Cannot resolve host name %s --- exiting!\n", w);
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "Cannot resolve host name %s --- exiting!", w);
        exit(1);
     }
 
     if (hep->h_addr_list[1]) {
-       fprintf(stderr, "Host %s has multiple addresses ---\n", w);
-       fprintf(stderr, "you must choose one explicitly for use as\n");
-       fprintf(stderr, "a virtual host.  Exiting!!!\n");
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "Host %s has multiple addresses ---", w);
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "you must choose one explicitly for use as");
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "a virtual host.  Exiting!!!");
        exit(1);
     }
 
@@ -1991,9 +1991,11 @@ char *ap_get_local_host(ap_context_t *a)
     }
     str[MAXHOSTNAMELEN] = '\0';
     if ((!(p = gethostbyname(str))) || (!(server_hostname = find_fqdn(a, p)))) {
-       fprintf(stderr, "%s: cannot determine local host name.\n",
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
+                     "%s: cannot determine local host name.",
                ap_server_argv0);
-       fprintf(stderr, "Use the ServerName directive to set it manually.\n");
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
+                     "Use the ServerName directive to set it manually.");
        exit(1);
     }