From 0b7e65c3c91bc5c55166f58e467d808998e07527 Mon Sep 17 00:00:00 2001 From: Philipp Schafft Date: Fri, 7 Nov 2014 11:18:54 +0000 Subject: [PATCH] send errorlog (loglevel WARN) to stderr prior to opening the real logfiles. closes #1886 svn path=/icecast/trunk/icecast/; revision=19271 --- src/main.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index 9a80bb69..52ca0fb1 100644 --- a/src/main.c +++ b/src/main.c @@ -200,6 +200,16 @@ static int _parse_config_opts(int argc, char **argv, char *filename, int size) return -1; } +static int _start_logging_stdout(void) { + errorlog = log_open_file(stderr); + if ( errorlog < 0 ) + return 0; + + log_set_level(errorlog, 2 /* WARN */); + + return 1; +} + static int _start_logging(void) { char fn_error[FILENAME_MAX]; @@ -218,8 +228,7 @@ static int _start_logging(void) log_set_trigger (errorlog, config->logsize); log_set_archive_timestamp(errorlog, config->logarchive); } else { - errorlog = log_open_file(stderr); - log_to_stderr = 1; + /* this is already in place because of _start_logging_stdout() */ } if (errorlog < 0) { @@ -434,6 +443,11 @@ int main(int argc, char **argv) #if !defined(_WIN32) || defined(_CONSOLE) || defined(__MINGW32__) || defined(__MINGW64__) /* startup all the modules */ initialize_subsystems(); + if (!_start_logging_stdout()) { + _fatal_error("FATAL: Could not start logging on stderr."); + shutdown_subsystems(); + return 1; + } #endif /* parse the config file */ config_get_config();