MCPcopy Create free account
hub / github.com/apache/httpd / open_error_log

Function open_error_log

server/log.c:367–467  ·  view source on GitHub ↗

Open the error log for the given server_rec. If IS_MAIN is * non-zero, s is the main server. */

Source from the content-addressed store, hash-verified

365/* Open the error log for the given server_rec. If IS_MAIN is
366 * non-zero, s is the main server. */
367static int open_error_log(server_rec *s, int is_main, apr_pool_t *p)
368{
369 const char *fname;
370 int rc;
371
372 if (*s->error_fname == '|') {
373 apr_file_t *dummy = NULL;
374 apr_cmdtype_e cmdtype = APR_PROGRAM_ENV;
375 fname = s->error_fname + 1;
376
377 /* In 2.4 favor PROGRAM_ENV, accept "||prog" syntax for compatibility
378 * and "|$cmd" to override the default.
379 * Any 2.2 backport would continue to favor SHELLCMD_ENV so there
380 * accept "||prog" to override, and "|$cmd" to ease conversion.
381 */
382 if (*fname == '|')
383 ++fname;
384 if (*fname == '$') {
385 cmdtype = APR_SHELLCMD_ENV;
386 ++fname;
387 }
388
389 /* Spawn a new child logger. If this is the main server_rec,
390 * the new child must use a dummy stderr since the current
391 * stderr might be a pipe to the old logger. Otherwise, the
392 * child inherits the parents stderr. */
393 rc = log_child(p, fname, &dummy, cmdtype, is_main);
394 if (rc != APR_SUCCESS) {
395 ap_log_error(APLOG_MARK, APLOG_STARTUP, rc, ap_server_conf, APLOGNO(00089)
396 "Couldn't start ErrorLog process '%s'.",
397 s->error_fname + 1);
398 return DONE;
399 }
400
401 s->error_log = dummy;
402 }
403
404#ifdef HAVE_SYSLOG
405 else if (strcmp(s->error_fname, "syslog") == 0
406 || strncmp(s->error_fname, "syslog:", 7) == 0) {
407 if ((fname = strchr(s->error_fname, ':'))) {
408 /* s->error_fname could be [level]:[tag] (see #60525) */
409 const char *tag;
410 apr_size_t flen;
411 const TRANS *fac;
412
413 fname++;
414 tag = ap_strchr_c(fname, ':');
415 if (tag) {
416 flen = tag - fname;
417 tag++;
418 if (*tag == '\0') {
419 tag = ap_server_argv0;
420 }
421 } else {
422 flen = strlen(fname);
423 tag = ap_server_argv0;
424 }

Callers 1

ap_open_logsFunction · 0.85

Calls 4

log_childFunction · 0.85
ap_strchr_cFunction · 0.85
ap_server_root_relativeFunction · 0.85
ap_log_errorFunction · 0.50

Tested by

no test coverage detected