842ae4bd224140319ae7feec1872b93dfd491143fielding/* Licensed to the Apache Software Foundation (ASF) under one or more
842ae4bd224140319ae7feec1872b93dfd491143fielding * contributor license agreements. See the NOTICE file distributed with
842ae4bd224140319ae7feec1872b93dfd491143fielding * this work for additional information regarding copyright ownership.
842ae4bd224140319ae7feec1872b93dfd491143fielding * The ASF licenses this file to You under the Apache License, Version 2.0
842ae4bd224140319ae7feec1872b93dfd491143fielding * (the "License"); you may not use this file except in compliance with
842ae4bd224140319ae7feec1872b93dfd491143fielding * the License. You may obtain a copy of the License at
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * Unless required by applicable law or agreed to in writing, software
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * distributed under the License is distributed on an "AS IS" BASIS,
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * See the License for the specific language governing permissions and
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * limitations under the License.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * http_log.c: Dealing with the logs and errors
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Rob McCool
7184de27ec1d62a83c41cdeac0953ca9fd661e8csf/* we know core's module_index is 0 */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingtypedef struct {
cb9e6e5c78f5a1690214e9548250fc6af1fc73b5wroweint AP_DECLARE_DATA ap_default_loglevel = DEFAULT_LOGLEVEL;
82d2a5debc5a6ed2118ac5916d9ba36ad0b5d78btrawick/* track pipe handles to close in child process */
5bfaaf573bacb45c1cf290ce85ecc676587e8a64jim * @brief The piped logging structure.
5bfaaf573bacb45c1cf290ce85ecc676587e8a64jim * Piped logs are used to move functionality out of the main server.
f3a0be90718c1fa5da1bf25e38974d2db3ef8a30jorton * For example, log rotation is done with piped logs.
f3a0be90718c1fa5da1bf25e38974d2db3ef8a30jorton /** The pool to use for the piped log */
f3a0be90718c1fa5da1bf25e38974d2db3ef8a30jorton /** The pipe between the server and the logging process */
f3a0be90718c1fa5da1bf25e38974d2db3ef8a30jorton /** The name of the program the logging process is running */
f3a0be90718c1fa5da1bf25e38974d2db3ef8a30jorton /** The pid of the logging process */
7117ace448072813fa6eb7180ef206fc2e8fcfc7wrowe /** How to reinvoke program when it must be replaced */
f3a0be90718c1fa5da1bf25e38974d2db3ef8a30jortonAP_DECLARE(apr_file_t *) ap_piped_log_read_fd(piped_log *pl)
f3a0be90718c1fa5da1bf25e38974d2db3ef8a30jortonAP_DECLARE(apr_file_t *) ap_piped_log_write_fd(piped_log *pl)
d7b781abdcdc6fc4d4fcd513d5babd3c42dff43dwrowe/* remember to close this handle in the child process
d7b781abdcdc6fc4d4fcd513d5babd3c42dff43dwrowe * On Win32 this makes zero sense, because we don't
d7b781abdcdc6fc4d4fcd513d5babd3c42dff43dwrowe * take the parent process's child procs.
d7b781abdcdc6fc4d4fcd513d5babd3c42dff43dwrowe * If the win32 parent instead passed each and every
d7b781abdcdc6fc4d4fcd513d5babd3c42dff43dwrowe * logger write handle from itself down to the child,
5bfaaf573bacb45c1cf290ce85ecc676587e8a64jim * and the parent manages all aspects of keeping the
d7b781abdcdc6fc4d4fcd513d5babd3c42dff43dwrowe * reliable pipe log children alive, this would still
d7b781abdcdc6fc4d4fcd513d5babd3c42dff43dwrowe * make no sense :) Cripple it on Win32.
82d2a5debc5a6ed2118ac5916d9ba36ad0b5d78btrawickstatic void close_handle_in_child(apr_pool_t *p, apr_file_t *f)
82d2a5debc5a6ed2118ac5916d9ba36ad0b5d78btrawickvoid ap_logs_child_init(apr_pool_t *p, server_rec *s)
e8f95a682820a599fe41b22977010636be5c2717jimAP_DECLARE(apr_status_t) ap_replace_stderr_log(apr_pool_t *p,
b3edf21d591bfd0e64bbec0dda73c0e41d7ecdb6wrowe const char *fname)
185aa71728867671e105178b4c66fbc22b65ae26sf APR_EBADPATH, NULL, APLOGNO(00085) "Invalid -E error log file %s",
185aa71728867671e105178b4c66fbc22b65ae26sf ap_log_error(APLOG_MARK, APLOG_STARTUP, rc, NULL, APLOGNO(00086)
b3edf21d591bfd0e64bbec0dda73c0e41d7ecdb6wrowe "%s: could not open error log file %s.",
649c9dd342a580016d29c2866de88a4609eb6457wrowe /* This is safe provided we revert it when we are finished.
649c9dd342a580016d29c2866de88a4609eb6457wrowe * We don't manager the callers pool!
5bfaaf573bacb45c1cf290ce85ecc676587e8a64jim if ((rc = apr_file_open_stderr(&stderr_log, stderr_pool))
5bfaaf573bacb45c1cf290ce85ecc676587e8a64jim if ((rc = apr_file_dup2(stderr_log, stderr_file, stderr_pool))
649c9dd342a580016d29c2866de88a4609eb6457wrowe * You might ponder why stderr_pool should survive?
649c9dd342a580016d29c2866de88a4609eb6457wrowe * The trouble is, stderr_pool may have s_main->error_log,
649c9dd342a580016d29c2866de88a4609eb6457wrowe * so we aren't in a position to destory stderr_pool until
5bfaaf573bacb45c1cf290ce85ecc676587e8a64jim * the next recycle. There's also an apparent bug which
5bfaaf573bacb45c1cf290ce85ecc676587e8a64jim * is not; if some folk decided to call this function before
649c9dd342a580016d29c2866de88a4609eb6457wrowe * the core open error logs hook, this pool won't survive.
649c9dd342a580016d29c2866de88a4609eb6457wrowe * Neither does the stderr logger, so this isn't a problem.
649c9dd342a580016d29c2866de88a4609eb6457wrowe /* Revert, see above */
185aa71728867671e105178b4c66fbc22b65ae26sf ap_log_error(APLOG_MARK, APLOG_CRIT, rc, NULL, APLOGNO(00087)
760b90f5b0bb414646deb6a3a2a53c14bf49bf3dwrowe "unable to replace stderr with error log file");
76185d819b745e953dd2cd636fbdd515c333e4a4trawickstatic void log_child_errfn(apr_pool_t *pool, apr_status_t err,
185aa71728867671e105178b4c66fbc22b65ae26sf ap_log_error(APLOG_MARK, APLOG_ERR, err, NULL, APLOGNO(00088)
399cf0e5e061b49593817421b94305889fa6bc1fjorton/* Create a child process running PROGNAME with a pipe connected to
399cf0e5e061b49593817421b94305889fa6bc1fjorton * the childs stdin. The write-end of the pipe will be placed in
399cf0e5e061b49593817421b94305889fa6bc1fjorton * *FPIN on successful return. If dummy_stderr is non-zero, the
399cf0e5e061b49593817421b94305889fa6bc1fjorton * stderr for the child will be the same as the stdout of the parent.
399cf0e5e061b49593817421b94305889fa6bc1fjorton * Otherwise the child will inherit the stderr from the parent. */
1ccd992d37d62c8cb2056126f2234f64ec189bfddougmstatic int log_child(apr_pool_t *p, const char *progname,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding /* Child process code for 'ErrorLog "|..."';
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * may want a common framework for this, since I expect it will
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * be common for other foo-loggers to want this sort of thing...
2261031aa94be82d7e6b1b8c367afc1b282317f5ianh if (((rc = apr_procattr_create(&procattr, p)) == APR_SUCCESS)
7117ace448072813fa6eb7180ef206fc2e8fcfc7wrowe && ((rc = apr_procattr_cmdtype_set(procattr, cmdtype)) == APR_SUCCESS)
76185d819b745e953dd2cd636fbdd515c333e4a4trawick && ((rc = apr_procattr_error_check_set(procattr, 1)) == APR_SUCCESS)
5bfaaf573bacb45c1cf290ce85ecc676587e8a64jim && ((rc = apr_procattr_child_errfn_set(procattr, log_child_errfn))
8a3228198adb03e6996f7738c361a612777ecab6aaron procnew = (apr_proc_t *)apr_pcalloc(p, sizeof(*procnew));
ff0436077dc959b17a6f87825e4a106d211224c1wrowe if ((rc = apr_file_open_stdout(&errfile, p)) == APR_SUCCESS)
ff0436077dc959b17a6f87825e4a106d211224c1wrowe rc = apr_procattr_child_err_set(procattr, errfile, NULL);
f205c4528c66355765990fe9785c17832c656d97trawick rc = apr_proc_create(procnew, args[0], (const char * const *)args,
d521bfef0e1a65993d5e302628ac68a2c91a195ftrawick apr_pool_note_subprocess(p, procnew, APR_KILL_AFTER_TIMEOUT);
82d2a5debc5a6ed2118ac5916d9ba36ad0b5d78btrawick /* read handle to pipe not kept open, so no need to call
82d2a5debc5a6ed2118ac5916d9ba36ad0b5d78btrawick * close_handle_in_child()
399cf0e5e061b49593817421b94305889fa6bc1fjorton/* Open the error log for the given server_rec. If IS_MAIN is
399cf0e5e061b49593817421b94305889fa6bc1fjorton * non-zero, s is the main server. */
399cf0e5e061b49593817421b94305889fa6bc1fjortonstatic int open_error_log(server_rec *s, int is_main, apr_pool_t *p)
7117ace448072813fa6eb7180ef206fc2e8fcfc7wrowe /* In 2.4 favor PROGRAM_ENV, accept "||prog" syntax for compatibility
7117ace448072813fa6eb7180ef206fc2e8fcfc7wrowe * and "|$cmd" to override the default.
5bfaaf573bacb45c1cf290ce85ecc676587e8a64jim * Any 2.2 backport would continue to favor SHELLCMD_ENV so there
7117ace448072813fa6eb7180ef206fc2e8fcfc7wrowe * accept "||prog" to override, and "|$cmd" to ease conversion.
399cf0e5e061b49593817421b94305889fa6bc1fjorton /* Spawn a new child logger. If this is the main server_rec,
399cf0e5e061b49593817421b94305889fa6bc1fjorton * the new child must use a dummy stderr since the current
399cf0e5e061b49593817421b94305889fa6bc1fjorton * stderr might be a pipe to the old logger. Otherwise, the
399cf0e5e061b49593817421b94305889fa6bc1fjorton * child inherits the parents stderr. */
185aa71728867671e105178b4c66fbc22b65ae26sf ap_log_error(APLOG_MARK, APLOG_STARTUP, rc, NULL, APLOGNO(00089)
19702a9985f3b2f794d22be9102d9d4fbf6bebe7rjung "Couldn't start ErrorLog process '%s'.",
56589be3d7a3e9343370df240010c6928cc78b39jkaluza else if (s->errorlog_provider) {
56589be3d7a3e9343370df240010c6928cc78b39jkaluza s->errorlog_provider_handle = s->errorlog_provider->init(p, s);
c62cc8593d17deefcd6879923ccfcd80f07eaa40trawick /* provider must log something to the console */
185aa71728867671e105178b4c66fbc22b65ae26sf ap_log_error(APLOG_MARK, APLOG_STARTUP, APR_EBADPATH, NULL, APLOGNO(00090)
053847fad1e0bfc79d75dd6aec040b78c4d9189erjung "%s: Invalid error log path %s.",
185aa71728867671e105178b4c66fbc22b65ae26sf ap_log_error(APLOG_MARK, APLOG_STARTUP, rc, NULL, APLOGNO(00091)
053847fad1e0bfc79d75dd6aec040b78c4d9189erjung "%s: could not open error log file %s.",
e8f95a682820a599fe41b22977010636be5c2717jimint ap_open_logs(apr_pool_t *pconf, apr_pool_t *p /* plog */,
649c9dd342a580016d29c2866de88a4609eb6457wrowe /* Register to throw away the read_handles list when we
649c9dd342a580016d29c2866de88a4609eb6457wrowe * cleanup plog. Upon fork() for the apache children,
649c9dd342a580016d29c2866de88a4609eb6457wrowe * this read_handles list is closed so only the parent
5bfaaf573bacb45c1cf290ce85ecc676587e8a64jim * can relaunch a lost log child. These read handles
649c9dd342a580016d29c2866de88a4609eb6457wrowe * are always closed on exec.
5bfaaf573bacb45c1cf290ce85ecc676587e8a64jim * We won't care what happens to our stderr log child
5bfaaf573bacb45c1cf290ce85ecc676587e8a64jim * between log phases, so we don't mind losing stderr's
649c9dd342a580016d29c2866de88a4609eb6457wrowe * read_handle a little bit early.
f6e47621625cca111811e84e407be84b5b18e9c5sf apr_pool_cleanup_register(p, &read_handles, ap_pool_cleanup_set_null,
649c9dd342a580016d29c2866de88a4609eb6457wrowe /* HERE we need a stdout log that outlives plog.
5bfaaf573bacb45c1cf290ce85ecc676587e8a64jim * We *presume* the parent of plog is a process
649c9dd342a580016d29c2866de88a4609eb6457wrowe * or global pool which spans server restarts.
649c9dd342a580016d29c2866de88a4609eb6457wrowe * Create our stderr_pool as a child of the plog's
649c9dd342a580016d29c2866de88a4609eb6457wrowe * parent pool.
ab43b4a17b2ac31ccb1cf280be8c42a8a314cecbjorton /* Replace existing stderr with new log. */
649c9dd342a580016d29c2866de88a4609eb6457wrowe rv = apr_file_dup2(stderr_log, s_main->error_log, stderr_p);
185aa71728867671e105178b4c66fbc22b65ae26sf ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s_main, APLOGNO(00092)
ec727afb817df0e5202135278c0d2902923cc980stoddard "unable to replace stderr with error_log");
649c9dd342a580016d29c2866de88a4609eb6457wrowe /* We are done with stderr_pool, close it, killing
649c9dd342a580016d29c2866de88a4609eb6457wrowe * the previous generation's stderr logger
188dff19ac1e71ffd25752d1a4f8d71f9f563305wrowe * Now that we have dup'ed s_main->error_log to stderr_log
188dff19ac1e71ffd25752d1a4f8d71f9f563305wrowe * close it and set s_main->error_log to stderr_log. This avoids
188dff19ac1e71ffd25752d1a4f8d71f9f563305wrowe * this fd being inherited by the next piped logger who would
188dff19ac1e71ffd25752d1a4f8d71f9f563305wrowe * keep open the writing end of the pipe that this one uses
188dff19ac1e71ffd25752d1a4f8d71f9f563305wrowe * as stdin. This in turn would prevent the piped logger from
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding /* note that stderr may still need to be replaced with something
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * because it points to the old error log, or back to the tty
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * of the submitter.
0f57a69cc84c59eacda1179763ae42ca88f1a577wrowe * XXX: This is BS - /dev/null is non-portable
6850c836b8c7c688ef8a8ec280e798e1d0bfbf01trawick * errno-as-apr_status_t is also non-portable
5cf689302f66ca316fc1108ad4c1d096760ab482jkaluza ap_log_error(APLOG_MARK, APLOG_CRIT, errno, s_main, APLOGNO(00093)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding for (virt = s_main->next; virt; virt = virt->next) {
8a3228198adb03e6996f7738c361a612777ecab6aaron if (q == virt) {
96993ca23bcd7be8de934a111988e59e96187d81trawick /* separately-configured vhost-specific provider */
96993ca23bcd7be8de934a111988e59e96187d81trawick /* inherit provider from s_main */
96993ca23bcd7be8de934a111988e59e96187d81trawick virt->errorlog_provider = s_main->errorlog_provider;
96993ca23bcd7be8de934a111988e59e96187d81trawick virt->errorlog_provider_handle = s_main->errorlog_provider_handle;
bdf833c0329ee171eb99efe9c037b6ed653c5007aaron apr_file_dup2(s->error_log, errfile, s->process->pool);
e302f38fd646764ce1a1e1c578d794aef514a9e5sfstatic int cpystrn(char *buf, const char *arg, int buflen)
e302f38fd646764ce1a1e1c578d794aef514a9e5sfstatic int log_remote_address(const ap_errorlog_info *info, const char *arg,
4240daa133bbeddbc3141553879eda4fccfe93feminfrin return apr_snprintf(buf, buflen, "%s:%d", info->r->useragent_ip,
6d6cd31bddca0b7d9cf9d18e46cd2361530e24f3sf info->r->useragent_addr ? info->r->useragent_addr->port : 0);
49fd87ed00b95bdd7a4cfc874e5c5fe4a04faf5aminfrin else if (info->c)
c41be3600a58bd39a76d1215abcdbbd8e9b1c356minfrin return apr_snprintf(buf, buflen, "%s:%d", info->c->client_ip,
e302f38fd646764ce1a1e1c578d794aef514a9e5sfstatic int log_local_address(const ap_errorlog_info *info, const char *arg,
e302f38fd646764ce1a1e1c578d794aef514a9e5sf return apr_snprintf(buf, buflen, "%s:%d", info->c->local_ip,
e302f38fd646764ce1a1e1c578d794aef514a9e5sfstatic int log_pid(const ap_errorlog_info *info, const char *arg,
e302f38fd646764ce1a1e1c578d794aef514a9e5sf return apr_snprintf(buf, buflen, "%" APR_PID_T_FMT, pid);
e302f38fd646764ce1a1e1c578d794aef514a9e5sfstatic int log_tid(const ap_errorlog_info *info, const char *arg,
e302f38fd646764ce1a1e1c578d794aef514a9e5sf if (ap_mpm_query(AP_MPMQ_IS_THREADED, &result) == APR_SUCCESS
e302f38fd646764ce1a1e1c578d794aef514a9e5sfstatic int log_ctime(const ap_errorlog_info *info, const char *arg,
e302f38fd646764ce1a1e1c578d794aef514a9e5sf switch (*arg) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf ap_recent_ctime_ex(buf, apr_time_now(), option, &time_len);
e302f38fd646764ce1a1e1c578d794aef514a9e5sf /* ap_recent_ctime_ex includes the trailing \0 in time_len */
e302f38fd646764ce1a1e1c578d794aef514a9e5sfstatic int log_loglevel(const ap_errorlog_info *info, const char *arg,
e302f38fd646764ce1a1e1c578d794aef514a9e5sf return cpystrn(buf, priorities[info->level].t_name, buflen);
e302f38fd646764ce1a1e1c578d794aef514a9e5sfstatic int log_log_id(const ap_errorlog_info *info, const char *arg,
e302f38fd646764ce1a1e1c578d794aef514a9e5sf * C: log conn log_id if available,
e302f38fd646764ce1a1e1c578d794aef514a9e5sf * c: log conn log id if available and not a once-per-request log line
e302f38fd646764ce1a1e1c578d794aef514a9e5sf * else: log request log id if available
e302f38fd646764ce1a1e1c578d794aef514a9e5sfstatic int log_keepalives(const ap_errorlog_info *info, const char *arg,
e302f38fd646764ce1a1e1c578d794aef514a9e5sf return apr_snprintf(buf, buflen, "%d", info->c->keepalives);
e302f38fd646764ce1a1e1c578d794aef514a9e5sfstatic int log_module_name(const ap_errorlog_info *info, const char *arg,
e302f38fd646764ce1a1e1c578d794aef514a9e5sf return cpystrn(buf, ap_find_module_short_name(info->module_index), buflen);
e302f38fd646764ce1a1e1c578d794aef514a9e5sfstatic int log_file_line(const ap_errorlog_info *info, const char *arg,
0ef41d8e4b94d343e5b093c4dbd6ee61c1279401trawick#if defined(_OSD_POSIX) || defined(WIN32) || defined(__MVS__)
8a3228198adb03e6996f7738c361a612777ecab6aaron /* In OSD/POSIX, the compiler returns for __FILE__
8a3228198adb03e6996f7738c361a612777ecab6aaron * a string like: __FILE__="*POSIX(/usr/include/stdio.h)"
8a3228198adb03e6996f7738c361a612777ecab6aaron * (it even returns an absolute path for sources in
8a3228198adb03e6996f7738c361a612777ecab6aaron * the current directory). Here we try to strip this
8a3228198adb03e6996f7738c361a612777ecab6aaron * down to the basename.
8a3228198adb03e6996f7738c361a612777ecab6aaron if (*e == ')') {
50e421c0e069853bb724f3d816cef543e447c844jorton#else /* _OSD_POSIX || WIN32 */
50e421c0e069853bb724f3d816cef543e447c844jorton const char *p;
50e421c0e069853bb724f3d816cef543e447c844jorton /* On Unix, __FILE__ may be an absolute path in a
50e421c0e069853bb724f3d816cef543e447c844jorton * VPATH build. */
50e421c0e069853bb724f3d816cef543e447c844jorton if (file[0] == '/' && (p = ap_strrchr_c(file, '/')) != NULL) {
50e421c0e069853bb724f3d816cef543e447c844jorton#endif /*_OSD_POSIX || WIN32 */
e302f38fd646764ce1a1e1c578d794aef514a9e5sf return apr_snprintf(buf, buflen, "%s(%d)", file, info->line);
e302f38fd646764ce1a1e1c578d794aef514a9e5sfstatic int log_apr_status(const ap_errorlog_info *info, const char *arg,
9228509ac5da8374df4a5d50b7da139e7b31f8a3sfstatic int log_server_name(const ap_errorlog_info *info, const char *arg,
9228509ac5da8374df4a5d50b7da139e7b31f8a3sf return cpystrn(buf, ap_get_server_name((request_rec *)info->r), buflen);
9228509ac5da8374df4a5d50b7da139e7b31f8a3sfstatic int log_virtual_host(const ap_errorlog_info *info, const char *arg,
4497075b5e08b0c8ee89425a1758258ae80550fcsfstatic int log_table_entry(const apr_table_t *table, const char *name,
4497075b5e08b0c8ee89425a1758258ae80550fcsfstatic int log_header(const ap_errorlog_info *info, const char *arg,
4497075b5e08b0c8ee89425a1758258ae80550fcsf return log_table_entry(info->r->headers_in, arg, buf, buflen);
4497075b5e08b0c8ee89425a1758258ae80550fcsfstatic int log_note(const ap_errorlog_info *info, const char *arg,
4497075b5e08b0c8ee89425a1758258ae80550fcsf /* XXX: maybe escaping the entry is not necessary for notes? */
4497075b5e08b0c8ee89425a1758258ae80550fcsf return log_table_entry(info->r->notes, arg, buf, buflen);
4497075b5e08b0c8ee89425a1758258ae80550fcsfstatic int log_env_var(const ap_errorlog_info *info, const char *arg,
4497075b5e08b0c8ee89425a1758258ae80550fcsf return log_table_entry(info->r->subprocess_env, arg, buf, buflen);
ce4dc40a4e87991087488f70d96d3447d7557294sfstatic int core_generate_log_id(const conn_rec *c, const request_rec *r,
ce4dc40a4e87991087488f70d96d3447d7557294sf const char **idstring)
e302f38fd646764ce1a1e1c578d794aef514a9e5sf if (r && r->request_time) {
06bc0ed097a567a63ec01ce7b8044221478cb5cdsf len = apr_base64_encode_len(sizeof(id)); /* includes trailing \0 */
06bc0ed097a567a63ec01ce7b8044221478cb5cdsf /* Skip the last char, it is always '=' */
ce4dc40a4e87991087488f70d96d3447d7557294sfstatic void add_log_id(const conn_rec *c, const request_rec *r)
e302f38fd646764ce1a1e1c578d794aef514a9e5sf /* need to cast const away */
ce4dc40a4e87991087488f70d96d3447d7557294sf ap_hook_generate_log_id(core_generate_log_id, NULL, NULL,
ce4dc40a4e87991087488f70d96d3447d7557294sf ap_register_errorlog_handler(p, "a", log_remote_address, 0);
ce4dc40a4e87991087488f70d96d3447d7557294sf ap_register_errorlog_handler(p, "A", log_local_address, 0);
ce4dc40a4e87991087488f70d96d3447d7557294sf ap_register_errorlog_handler(p, "m", log_module_name, 0);
9228509ac5da8374df4a5d50b7da139e7b31f8a3sf ap_register_errorlog_handler(p, "v", log_virtual_host, 0);
9228509ac5da8374df4a5d50b7da139e7b31f8a3sf ap_register_errorlog_handler(p, "V", log_server_name, 0);
e302f38fd646764ce1a1e1c578d794aef514a9e5sf * This is used if no error log format is defined and during startup.
56589be3d7a3e9343370df240010c6928cc78b39jkaluza * It automatically omits the timestamp if logging using provider.
e302f38fd646764ce1a1e1c578d794aef514a9e5sfstatic int do_errorlog_default(const ap_errorlog_info *info, char *buf,
e302f38fd646764ce1a1e1c578d794aef514a9e5sf len += log_module_name(info, NULL, buf + len, buflen - len);
e302f38fd646764ce1a1e1c578d794aef514a9e5sf len += log_loglevel(info, NULL, buf + len, buflen - len);
e302f38fd646764ce1a1e1c578d794aef514a9e5sf item_len = log_file_line(info, NULL, buf + len, buflen - len);
e302f38fd646764ce1a1e1c578d794aef514a9e5sf item_len = log_apr_status(info, NULL, buf + len, buflen - len);
c41be3600a58bd39a76d1215abcdbbd8e9b1c356minfrin * useragent_ip/client_ip can be client or backend server. If we have
4240daa133bbeddbc3141553879eda4fccfe93feminfrin * a scoreboard handle, it is likely a client.
49fd87ed00b95bdd7a4cfc874e5c5fe4a04faf5aminfrin info->r->connection->sbh ? "[client %s:%d] " : "[remote %s:%d] ",
6d6cd31bddca0b7d9cf9d18e46cd2361530e24f3sf info->r->useragent_addr ? info->r->useragent_addr->port : 0);
49fd87ed00b95bdd7a4cfc874e5c5fe4a04faf5aminfrin else if (info->c) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf /* the actual error message */
e302f38fd646764ce1a1e1c578d794aef514a9e5sf if (apr_vsnprintf(scratch, MAX_STRING_LEN, errstr_fmt, args)) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf len += apr_vsnprintf(buf + len, buflen - len, errstr_fmt, args);
e302f38fd646764ce1a1e1c578d794aef514a9e5sf item_len = log_header(info, "Referer", buf + len, buflen - len);
e302f38fd646764ce1a1e1c578d794aef514a9e5sfstatic int do_errorlog_format(apr_array_header_t *fmt, ap_errorlog_info *info,
e302f38fd646764ce1a1e1c578d794aef514a9e5sf ap_errorlog_format_item *items = (ap_errorlog_format_item *)fmt->elts;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf /* the actual error message */
e302f38fd646764ce1a1e1c578d794aef514a9e5sf if (apr_vsnprintf(scratch, MAX_STRING_LEN, err_fmt, args)) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf len += apr_vsnprintf(buf + len, buflen - len, err_fmt, args);
e302f38fd646764ce1a1e1c578d794aef514a9e5sf else if (skipping) {
ee2c610570b9e159784e87e72d1c17f459b85768sf else if (info->level != -1 && (int)item->min_loglevel > info->level) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf /* required item is empty. skip whole line */
e302f38fd646764ce1a1e1c578d794aef514a9e5sf else if (item->flags & AP_ERRORLOG_FLAG_NULL_AS_HYPHEN) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sfstatic void write_logline(char *errstr, apr_size_t len, apr_file_t *logf,
e302f38fd646764ce1a1e1c578d794aef514a9e5sfstatic void log_error_core(const char *file, int line, int module_index,
e302f38fd646764ce1a1e1c578d794aef514a9e5sf /* do we need to log once-per-req or once-per-conn info? */
e302f38fd646764ce1a1e1c578d794aef514a9e5sf if (s == NULL) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf * If we are doing stderr logging (startup), don't log messages that are
e302f38fd646764ce1a1e1c578d794aef514a9e5sf * above the default server log level unless it is a startup/shutdown
5cf689302f66ca316fc1108ad4c1d096760ab482jkaluza if (!logf && ap_server_conf && ap_server_conf->errorlog_provider) {
5cf689302f66ca316fc1108ad4c1d096760ab482jkaluza errorlog_provider = ap_server_conf->errorlog_provider;
5cf689302f66ca316fc1108ad4c1d096760ab482jkaluza errorlog_provider_handle = ap_server_conf->errorlog_provider_handle;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf int configured_level = r ? ap_get_request_module_loglevel(r, module_index) :
e302f38fd646764ce1a1e1c578d794aef514a9e5sf c ? ap_get_conn_server_module_loglevel(c, s, module_index) :
ac7ac5b79da100d59b176914c0d9448fadc03568trawick * If we are doing normal logging, don't log messages that are
ac7ac5b79da100d59b176914c0d9448fadc03568trawick * above the module's log level unless it is a startup/shutdown notice
5cf689302f66ca316fc1108ad4c1d096760ab482jkaluza errorlog_provider_handle = s->errorlog_provider_handle;
a8eeeed944c5d1986ab92649271d29839abd1155sf /* the faked server_rec from mod_cgid does not have s->module_config */
a8eeeed944c5d1986ab92649271d29839abd1155sf if (c && !c->log_id) {
a8eeeed944c5d1986ab92649271d29839abd1155sf if (sconf->error_log_conn && sconf->error_log_conn->nelts > 0)
a8eeeed944c5d1986ab92649271d29839abd1155sf /* XXX: do we need separate log ids for subrequests? */
a8eeeed944c5d1986ab92649271d29839abd1155sf if (sconf->error_log_req && sconf->error_log_req->nelts > 0)
a8eeeed944c5d1986ab92649271d29839abd1155sf * XXX: potential optimization: only create log id if %L is
a8eeeed944c5d1986ab92649271d29839abd1155sf * XXX: actually used
db8a047604be99acfb4849ae58a476e9b5872d86trawick if (!logf && !(errorlog_provider && errorlog_provider_handle)) {
5cf689302f66ca316fc1108ad4c1d096760ab482jkaluza /* There is no file to send the log message to (or it is
5cf689302f66ca316fc1108ad4c1d096760ab482jkaluza * redirected to /dev/null and therefore any formating done below
db8a047604be99acfb4849ae58a476e9b5872d86trawick * would be lost anyway) and there is no initialized log provider
db8a047604be99acfb4849ae58a476e9b5872d86trawick * available, so we just return here.
e302f38fd646764ce1a1e1c578d794aef514a9e5sf info.startup = ((level & APLOG_STARTUP) == APLOG_STARTUP);
e302f38fd646764ce1a1e1c578d794aef514a9e5sf while (!done) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf /* XXX: potential optimization: format common prefixes only once */
e302f38fd646764ce1a1e1c578d794aef514a9e5sf /* once-per-connection info */
e302f38fd646764ce1a1e1c578d794aef514a9e5sf lines = (apr_array_header_t **)sconf->error_log_conn->elts;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf /* this is the last line of once-per-connection info */
e302f38fd646764ce1a1e1c578d794aef514a9e5sf /* once-per-request info */
e302f38fd646764ce1a1e1c578d794aef514a9e5sf lines = (apr_array_header_t **)sconf->error_log_req->elts;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf /* this is the last line of once-per-request info */
e302f38fd646764ce1a1e1c578d794aef514a9e5sf /* the actual error message */
e302f38fd646764ce1a1e1c578d794aef514a9e5sf * prepare and log one line
e302f38fd646764ce1a1e1c578d794aef514a9e5sf len += do_errorlog_format(log_format, &info, errstr + len,
e302f38fd646764ce1a1e1c578d794aef514a9e5sf len += do_errorlog_default(&info, errstr + len, MAX_STRING_LEN - len,
e302f38fd646764ce1a1e1c578d794aef514a9e5sf * Don't log empty lines. This can happen with once-per-conn/req
e302f38fd646764ce1a1e1c578d794aef514a9e5sf * info if an item with AP_ERRORLOG_FLAG_REQUIRED is NULL.
7cac5c72d80c4dc740e6ae7bae29d41ffdbd4b05jkaluza /* Truncate for the terminator (as apr_snprintf does) */
5cf689302f66ca316fc1108ad4c1d096760ab482jkaluza errorlog_provider->writer(&info, errorlog_provider_handle,
e11c9fa326e7bfa48bd9be5bae7037ae76b2612dsf * We don't call the error_log hook for per-request/per-conn
e11c9fa326e7bfa48bd9be5bae7037ae76b2612dsf * lines, and we only pass the actual log message, not the
e11c9fa326e7bfa48bd9be5bae7037ae76b2612dsf * prefix and suffix.
f87299dab99bc04b51a6b8cad51b6795db862c0atrawick/* For internal calls to log_error_core with self-composed arg lists */
f87299dab99bc04b51a6b8cad51b6795db862c0atrawickstatic void log_error_va_glue(const char *file, int line, int module_index,
f87299dab99bc04b51a6b8cad51b6795db862c0atrawick const char *fmt, ...)
f87299dab99bc04b51a6b8cad51b6795db862c0atrawick log_error_core(file, line, module_index, level, status, s, c, r, pool,
d37a236a4b64d0aeb4a8bbfd3978503af8c82765sfAP_DECLARE(void) ap_log_error_(const char *file, int line, int module_index,
d37a236a4b64d0aeb4a8bbfd3978503af8c82765sf log_error_core(file, line, module_index, level, status, s, NULL, NULL,
d37a236a4b64d0aeb4a8bbfd3978503af8c82765sfAP_DECLARE(void) ap_log_perror_(const char *file, int line, int module_index,
d37a236a4b64d0aeb4a8bbfd3978503af8c82765sf const char *fmt, ...)
d37a236a4b64d0aeb4a8bbfd3978503af8c82765sf log_error_core(file, line, module_index, level, status, NULL, NULL, NULL,
d37a236a4b64d0aeb4a8bbfd3978503af8c82765sfAP_DECLARE(void) ap_log_rerror_(const char *file, int line, int module_index,
d37a236a4b64d0aeb4a8bbfd3978503af8c82765sf log_error_core(file, line, module_index, level, status, r->server, NULL, r,
2b13bc45632d72cdf50ac42149e4fc8bc0d05bf2stoddard * IF APLOG_TOCLIENT is set,
2b13bc45632d72cdf50ac42149e4fc8bc0d05bf2stoddard * AND the error level is 'warning' or more severe,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * AND there isn't already error text associated with this request,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * THEN make the message text available to ErrorDocument and
2b13bc45632d72cdf50ac42149e4fc8bc0d05bf2stoddard * other error processors.
8a3228198adb03e6996f7738c361a612777ecab6aaron && (apr_table_get(r->notes, "error-notes") == NULL)) {
7538cfc9bcb1132e87011484b826c0d8bff9cc73sfAP_DECLARE(void) ap_log_cserror_(const char *file, int line, int module_index,
7538cfc9bcb1132e87011484b826c0d8bff9cc73sf const char *fmt, ...)
7538cfc9bcb1132e87011484b826c0d8bff9cc73sf log_error_core(file, line, module_index, level, status, s, c,
d37a236a4b64d0aeb4a8bbfd3978503af8c82765sfAP_DECLARE(void) ap_log_cerror_(const char *file, int line, int module_index,
d37a236a4b64d0aeb4a8bbfd3978503af8c82765sf log_error_core(file, line, module_index, level, status, c->base_server, c,
f87299dab99bc04b51a6b8cad51b6795db862c0atrawick#define LOG_BYTES_BUFFER_SIZE (BYTES_LOGGED_PER_LINE * 3 + 2)
f87299dab99bc04b51a6b8cad51b6795db862c0atrawickstatic void fmt_data(unsigned char *buf, const void *vdata, apr_size_t len, apr_size_t *off)
f87299dab99bc04b51a6b8cad51b6795db862c0atrawick const unsigned char *data = (const unsigned char *)vdata;
f87299dab99bc04b51a6b8cad51b6795db862c0atrawick hex = buf + BYTES_LOGGED_PER_LINE + 1; /* start hex dump here */
f87299dab99bc04b51a6b8cad51b6795db862c0atrawick while (*off < len && this_time < BYTES_LOGGED_PER_LINE) {
8e5d0fabc3ffbdfc8cfd9f61891f505e5204d72djailletc && c != '\\') { /* backslash will be escaped later, which throws
a79a6e9f0db6b6327053b0357f1d155b71db8182trawick * off the formatting
f87299dab99bc04b51a6b8cad51b6795db862c0atrawickstatic void log_data_core(const char *file, int line, int module_index,
f87299dab99bc04b51a6b8cad51b6795db862c0atrawick const char *label, const void *data, apr_size_t len,
f87299dab99bc04b51a6b8cad51b6795db862c0atrawick unsigned int flags)
f87299dab99bc04b51a6b8cad51b6795db862c0atrawick log_error_va_glue(file, line, module_index, level, APR_SUCCESS, s,
f87299dab99bc04b51a6b8cad51b6795db862c0atrawick apr_snprintf(prefix, sizeof prefix, "%04x: ", (unsigned int)off);
f87299dab99bc04b51a6b8cad51b6795db862c0atrawick log_error_va_glue(file, line, module_index, level, APR_SUCCESS, s,
f87299dab99bc04b51a6b8cad51b6795db862c0atrawickAP_DECLARE(void) ap_log_data_(const char *file, int line,
f87299dab99bc04b51a6b8cad51b6795db862c0atrawick unsigned int flags)
f87299dab99bc04b51a6b8cad51b6795db862c0atrawick log_data_core(file, line, module_index, level, s, NULL, NULL, label,
f87299dab99bc04b51a6b8cad51b6795db862c0atrawickAP_DECLARE(void) ap_log_rdata_(const char *file, int line,
f87299dab99bc04b51a6b8cad51b6795db862c0atrawick unsigned int flags)
f87299dab99bc04b51a6b8cad51b6795db862c0atrawick log_data_core(file, line, module_index, level, r->server, NULL, r, label,
f87299dab99bc04b51a6b8cad51b6795db862c0atrawickAP_DECLARE(void) ap_log_cdata_(const char *file, int line,
f87299dab99bc04b51a6b8cad51b6795db862c0atrawick unsigned int flags)
f87299dab99bc04b51a6b8cad51b6795db862c0atrawick log_data_core(file, line, module_index, level, c->base_server, c, NULL,
f87299dab99bc04b51a6b8cad51b6795db862c0atrawickAP_DECLARE(void) ap_log_csdata_(const char *file, int line, int module_index,
f87299dab99bc04b51a6b8cad51b6795db862c0atrawick log_data_core(file, line, module_index, level, s, c, NULL, label, data,
bd27541a0c96caa881f17a490e23cdd220d480c8poirierAP_DECLARE(void) ap_log_command_line(apr_pool_t *plog, server_rec *s)
bd27541a0c96caa881f17a490e23cdd220d480c8poirier /* Piece together the command line from the pieces
bd27541a0c96caa881f17a490e23cdd220d480c8poirier * in process->argv, with spaces in between.
185aa71728867671e105178b4c66fbc22b65ae26sf ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, s, APLOGNO(00094)
d981a6ecf6f7d394f1f017b19c52383e177a125ejim/* grab bag function to log commonly logged and shared info */
d981a6ecf6f7d394f1f017b19c52383e177a125ejim ap_log_error(APLOG_MARK, APLOG_DEBUG , 0, s, APLOGNO(02639)
d981a6ecf6f7d394f1f017b19c52383e177a125ejim "Using SO_REUSEPORT: %s (%d)",
20e0c71be778348516719e1e58a9f55c8e78c570trawickAP_DECLARE(void) ap_remove_pid(apr_pool_t *p, const char *rel_fname)
1ec73fc12d4912ea9f4841c301458454589b32d9trawick const char *fname = ap_runtime_dir_relative(p, rel_fname);
185aa71728867671e105178b4c66fbc22b65ae26sf ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf, APLOGNO(00095)
185aa71728867671e105178b4c66fbc22b65ae26sf ap_log_error(APLOG_MARK, APLOG_INFO, 0, ap_server_conf, APLOGNO(00096)
32c4bc04f89b16521718145dc731f750144d7b38wroweAP_DECLARE(void) ap_log_pid(apr_pool_t *p, const char *filename)
e8f95a682820a599fe41b22977010636be5c2717jim ap_log_error(APLOG_MARK, APLOG_STARTUP|APLOG_CRIT, APR_EBADPATH,
185aa71728867671e105178b4c66fbc22b65ae26sf NULL, APLOGNO(00097) "Invalid PID file path %s, ignoring.", filename);
8a3228198adb03e6996f7738c361a612777ecab6aaron && apr_stat(&finfo, fname, APR_FINFO_MTIME, p) == APR_SUCCESS) {
8a3228198adb03e6996f7738c361a612777ecab6aaron /* AP_SIG_GRACEFUL and HUP call this on each restart.
8a3228198adb03e6996f7738c361a612777ecab6aaron * Only warn on first time through for this pid.
8a3228198adb03e6996f7738c361a612777ecab6aaron * XXX: Could just write first time through too, although
8a3228198adb03e6996f7738c361a612777ecab6aaron * that may screw up scripts written to do something
8a3228198adb03e6996f7738c361a612777ecab6aaron * based on the last modification time of the pid file.
185aa71728867671e105178b4c66fbc22b65ae26sf ap_log_perror(APLOG_MARK, APLOG_WARNING, 0, p, APLOGNO(00098)
4bb7ba7c1f9972b443562faf99151ccec854446fjorton "pid file %s overwritten -- Unclean "
4bb7ba7c1f9972b443562faf99151ccec854446fjorton "shutdown of previous Apache run?",
185aa71728867671e105178b4c66fbc22b65ae26sf ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL, APLOGNO(00099)
185aa71728867671e105178b4c66fbc22b65ae26sf ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL, APLOGNO(00100)
2b484455736f4c30447aa852764f53282cbeb5ddrbb "%s: could not log pid to file %s",
95dc871e605e3b1b347adbbbdd9a9caede71c38eminfrin apr_file_printf(pid_file, "%" APR_PID_T_FMT APR_EOL_STR, mypid);
e3754dae9df2783c2cd88fa8d46bd0a0765e9820trawickAP_DECLARE(apr_status_t) ap_read_pid(apr_pool_t *p, const char *filename,
dc64949d88a97fef0bfcb2eed2115dddafc41666wrowe const apr_size_t BUFFER_SIZE = sizeof(long) * 3 + 2; /* see apr_ltoa */
e8f95a682820a599fe41b22977010636be5c2717jim ap_log_error(APLOG_MARK, APLOG_STARTUP|APLOG_CRIT, APR_EBADPATH,
185aa71728867671e105178b4c66fbc22b65ae26sf NULL, APLOGNO(00101) "Invalid PID file path %s, ignoring.", filename);
e3754dae9df2783c2cd88fa8d46bd0a0765e9820trawick rv = apr_file_open(&pid_file, fname, APR_READ, APR_OS_DEFAULT, p);
2de7ee14d4925c754a2d3a52d91350b895257df9jerenkrantz rv = apr_file_read_full(pid_file, buf, BUFFER_SIZE - 1, &bytes_read);
2de7ee14d4925c754a2d3a52d91350b895257df9jerenkrantz /* If we fill the buffer, we're probably reading a corrupt pid file.
2de7ee14d4925c754a2d3a52d91350b895257df9jerenkrantz * To be nice, let's also ensure the first char is a digit. */
f2b43354f9ac8496ab7003ae01211af739efba1atrawick if (bytes_read == 0 || bytes_read == BUFFER_SIZE - 1 || !apr_isdigit(*buf)) {
8a3228198adb03e6996f7738c361a612777ecab6aaronAP_DECLARE(void) ap_log_assert(const char *szExp, const char *szFile,
185aa71728867671e105178b4c66fbc22b65ae26sf ap_log_error(APLOG_MARK, APLOG_CRIT, 0, NULL, APLOGNO(00102)
2b484455736f4c30447aa852764f53282cbeb5ddrbb "[%s] file %s, line %d, assertion \"%s\" failed",
8f0d7adca1c0719b3b1863fb2b9d333d7822567awrowe#if defined(WIN32)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding /* unix assert does an abort leading to a core dump */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* piped log support */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* forward declaration */
10a4cdd68ef1ca0e54af296fe1d08ac00150c90bwrowestatic void piped_log_maintenance(int reason, void *data, apr_wait_t status);
f5308a6d396448120986bed14412954788af3e5cjorton/* Spawn the piped logger process pl->program. */
066877f1a045103acfdd376d48cdd473c33f409bdougm if (((status = apr_procattr_create(&procattr, pl->p)) != APR_SUCCESS) ||
5a6a87d8920e385b1ed14177d74ab9786f3acddfwrowe ((status = apr_procattr_dir_set(procattr, ap_server_root))
7117ace448072813fa6eb7180ef206fc2e8fcfc7wrowe ((status = apr_procattr_cmdtype_set(procattr, pl->cmdtype))
76185d819b745e953dd2cd636fbdd515c333e4a4trawick ((status = apr_procattr_child_errfn_set(procattr, log_child_errfn))
76185d819b745e953dd2cd636fbdd515c333e4a4trawick ((status = apr_procattr_error_check_set(procattr, 1)) != APR_SUCCESS)) {
2cfdca5be0c69f65b43a888d6d3da846489b8fa5rbb /* Something bad happened, give up and go away. */
31ffc4bd929e3c5dca2e329a52651c418b995fc1sf ap_log_error(APLOG_MARK, APLOG_STARTUP, status, NULL, APLOGNO(00103)
31ffc4bd929e3c5dca2e329a52651c418b995fc1sf "piped_log_spawn: unable to setup child process '%s'",
9aae81f4b0afaaaa6571e6f995dc0c5d5b5435e8trawick status = apr_proc_create(procnew, args[0], (const char * const *) args,
f3a0be90718c1fa5da1bf25e38974d2db3ef8a30jorton /* procnew->in was dup2'd from pl->write_fd;
38cf7a307a8067b5b476403b9fec0bc6d7849cd2jorton * since the original fd is still valid, close the copy to
38cf7a307a8067b5b476403b9fec0bc6d7849cd2jorton * avoid a leak. */
053847fad1e0bfc79d75dd6aec040b78c4d9189erjung apr_proc_other_child_register(procnew, piped_log_maintenance, pl,
76185d819b745e953dd2cd636fbdd515c333e4a4trawick /* Something bad happened, give up and go away. */
31ffc4bd929e3c5dca2e329a52651c418b995fc1sf ap_log_error(APLOG_MARK, APLOG_STARTUP, status, NULL, APLOGNO(00104)
31ffc4bd929e3c5dca2e329a52651c418b995fc1sf "unable to start piped log program '%s'",
10a4cdd68ef1ca0e54af296fe1d08ac00150c90bwrowestatic void piped_log_maintenance(int reason, void *data, apr_wait_t status)
874fa3c6bbef1b4ab4bed0a2ff9852b21ea1b187trawick pl->pid = NULL; /* in case we don't get it going again, this
874fa3c6bbef1b4ab4bed0a2ff9852b21ea1b187trawick * tells other logic not to try to kill it
185aa71728867671e105178b4c66fbc22b65ae26sf ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, APLOGNO(00105)
874fa3c6bbef1b4ab4bed0a2ff9852b21ea1b187trawick "can't query MPM state; not restarting "
874fa3c6bbef1b4ab4bed0a2ff9852b21ea1b187trawick "piped log program '%s'",
185aa71728867671e105178b4c66fbc22b65ae26sf ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, APLOGNO(00106)
874fa3c6bbef1b4ab4bed0a2ff9852b21ea1b187trawick "piped log program '%s' failed unexpectedly",
874fa3c6bbef1b4ab4bed0a2ff9852b21ea1b187trawick /* what can we do? This could be the error log we're having
874fa3c6bbef1b4ab4bed0a2ff9852b21ea1b187trawick * problems opening up... */
31ffc4bd929e3c5dca2e329a52651c418b995fc1sf ap_log_error(APLOG_MARK, APLOG_STARTUP, rv, NULL, APLOGNO(00107)
31ffc4bd929e3c5dca2e329a52651c418b995fc1sf "piped_log_maintenance: unable to respawn '%s'",
ffb048955d9939c0ab6ff99c2efc412d8e7a191dwrowe /* We should not kill off the pipe here, since it may only be full.
ffb048955d9939c0ab6ff99c2efc412d8e7a191dwrowe * If it really is locked, we should kill it off manually. */
c54189c4d2d06d8b374940b32acf20287effff07wrowestatic apr_status_t piped_log_cleanup_for_exec(void *data)
7117ace448072813fa6eb7180ef206fc2e8fcfc7wroweAP_DECLARE(piped_log *) ap_open_piped_log_ex(apr_pool_t *p,
7117ace448072813fa6eb7180ef206fc2e8fcfc7wrowe const char *program,
cddad5fd27fd3b9f4375d76d04bbbeaebec00548wrowe#else /* !AP_HAVE_RELIABLE_PIPED_LOGS */
7117ace448072813fa6eb7180ef206fc2e8fcfc7wroweAP_DECLARE(piped_log *) ap_open_piped_log_ex(apr_pool_t *p,
7117ace448072813fa6eb7180ef206fc2e8fcfc7wrowe const char *program,
185aa71728867671e105178b4c66fbc22b65ae26sf ap_log_error(APLOG_MARK, APLOG_STARTUP, rc, NULL, APLOGNO(00108)
19702a9985f3b2f794d22be9102d9d4fbf6bebe7rjung "Couldn't start piped log process '%s'.",
066877f1a045103acfdd376d48cdd473c33f409bdougm apr_pool_cleanup_register(p, pl, piped_log_cleanup, piped_log_cleanup);
7117ace448072813fa6eb7180ef206fc2e8fcfc7wroweAP_DECLARE(piped_log *) ap_open_piped_log(apr_pool_t *p,
7117ace448072813fa6eb7180ef206fc2e8fcfc7wrowe const char *program)
44c44a736f11c7785e87b8c4744b3867ad7d8f0bwrowe /* In 2.4 favor PROGRAM_ENV, accept "||prog" syntax for compatibility
44c44a736f11c7785e87b8c4744b3867ad7d8f0bwrowe * and "|$cmd" to override the default.
5bfaaf573bacb45c1cf290ce85ecc676587e8a64jim * Any 2.2 backport would continue to favor SHELLCMD_ENV so there
44c44a736f11c7785e87b8c4744b3867ad7d8f0bwrowe * accept "||prog" to override, and "|$cmd" to ease conversion.
aa51f4b9e1f954f9c04d2728a0d7be01719fe0a1sfAP_DECLARE(const char *) ap_parse_log_level(const char *str, int *val)
1119f286db67c139106e274e0814430cd600b901sf char *err = "Log level keyword must be one of emerg/alert/crit/error/warn/"
aa51f4b9e1f954f9c04d2728a0d7be01719fe0a1sf int i = 0;
ce4dc40a4e87991087488f70d96d3447d7557294sf const char **id),