From bef7e4e0222a4744b3ea3a66e5d59474f38b0252 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Fri, 23 Jul 2004 02:49:33 +0000 Subject: [PATCH] Make it even more explicit what went wrong when log opening failed, since many people don't seem to be able to figure it out. svn path=/icecast/trunk/icecast/; revision=7265 --- src/main.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index 3b6e82b4..4d4cf662 100644 --- a/src/main.c +++ b/src/main.c @@ -176,19 +176,24 @@ static int _start_logging(void) char fn_error[FILENAME_MAX]; char fn_access[FILENAME_MAX]; char buf[1024]; + int log_to_stderr; ice_config_t *config = config_get_config_unlocked(); if(strcmp(config->error_log, "-")) { snprintf(fn_error, FILENAME_MAX, "%s%s%s", config->log_dir, PATH_SEPARATOR, config->error_log); errorlog = log_open(fn_error); + log_to_stderr = 0; } else { errorlog = log_open_file(stderr); + log_to_stderr = 1; } if (errorlog < 0) { buf[sizeof(buf)-1] = 0; - snprintf(buf, sizeof(buf)-1, "FATAL: could not open error logging: %s", + snprintf(buf, sizeof(buf)-1, + "FATAL: could not open error logging (%s): %s", + log_to_stderr?"standard error":fn_error, strerror(errno)); _fatal_error(buf); } @@ -197,13 +202,17 @@ static int _start_logging(void) if(strcmp(config->access_log, "-")) { snprintf(fn_access, FILENAME_MAX, "%s%s%s", config->log_dir, PATH_SEPARATOR, config->access_log); accesslog = log_open(fn_access); + log_to_stderr = 0; } else { accesslog = log_open_file(stderr); + log_to_stderr = 1; } if (accesslog < 0) { buf[sizeof(buf)-1] = 0; - snprintf(buf, sizeof(buf)-1, "FATAL: could not open access logging: %s", + snprintf(buf, sizeof(buf)-1, + "FATAL: could not open access logging (%s): %s", + log_to_stderr?"standard error":fn_access, strerror(errno)); _fatal_error(buf); }