From 41c74985ce12128d8e9dc6db2d13f3038fa95875 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 26 Jan 2015 16:08:21 +1100 Subject: [PATCH] Print warning messages to console before attempting to log them in case of inability to write to the log --- src/ckpool.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ckpool.c b/src/ckpool.c index c2ca2348..ca07b3c2 100644 --- a/src/ckpool.c +++ b/src/ckpool.c @@ -81,6 +81,13 @@ void logmsg(int loglevel, const char *fmt, ...) { tm.tm_hour, tm.tm_min, tm.tm_sec); + if (loglevel <= LOG_WARNING) {\ + if (loglevel <= LOG_ERR && errno != 0) + fprintf(stderr, "%s %s with errno %d: %s\n", stamp, buf, errno, strerror(errno)); + else + fprintf(stderr, "%s %s\n", stamp, buf); + fflush(stderr); + } if (logfd) { char *msg; @@ -90,13 +97,6 @@ void logmsg(int loglevel, const char *fmt, ...) { ASPRINTF(&msg, "%s %s\n", stamp, buf); ckmsgq_add(global_ckp->logger, msg); } - if (loglevel <= LOG_WARNING) {\ - if (loglevel <= LOG_ERR && errno != 0) - fprintf(stderr, "%s %s with errno %d: %s\n", stamp, buf, errno, strerror(errno)); - else - fprintf(stderr, "%s %s\n", stamp, buf); - fflush(stderr); - } free(buf); } }