From: Marc Fournier Date: Tue, 10 Jan 2017 21:23:55 +0000 (+0100) Subject: logfile: send log messages to STDERR by default X-Git-Tag: collectd-5.7.2~16^2~2 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=9cb3abd9449a7f909c3434ec2ff0939939371269;p=collectd.git logfile: send log messages to STDERR by default This prevents early startup log messages from going unnoticed if the default logfile isn't writeable. Fixes: #2057 --- diff --git a/src/logfile.c b/src/logfile.c index e51c9db9..ef3aa97e 100644 --- a/src/logfile.c +++ b/src/logfile.c @@ -31,8 +31,6 @@ #include "common.h" #include "plugin.h" -#define DEFAULT_LOGFILE LOCALSTATEDIR "/log/collectd.log" - #if COLLECT_DEBUG static int log_level = LOG_DEBUG; #else @@ -118,8 +116,7 @@ static void logfile_print(const char *msg, int severity, pthread_mutex_lock(&file_lock); if (log_file == NULL) { - fh = fopen(DEFAULT_LOGFILE, "a"); - do_close = 1; + fh = stderr; } else if (strcasecmp(log_file, "stderr") == 0) fh = stderr; else if (strcasecmp(log_file, "stdout") == 0) @@ -131,8 +128,7 @@ static void logfile_print(const char *msg, int severity, if (fh == NULL) { char errbuf[1024]; - fprintf(stderr, "logfile plugin: fopen (%s) failed: %s\n", - (log_file == NULL) ? DEFAULT_LOGFILE : log_file, + fprintf(stderr, "logfile plugin: fopen (%s) failed: %s\n", log_file, sstrerror(errno, errbuf, sizeof(errbuf))); } else { if (print_timestamp)