Browse Source

Print warning messages to console before attempting to log them in case of inability to write to the log

master
Con Kolivas 10 years ago
parent
commit
41c74985ce
  1. 14
      src/ckpool.c

14
src/ckpool.c

@ -81,6 +81,13 @@ void logmsg(int loglevel, const char *fmt, ...) {
tm.tm_hour, tm.tm_hour,
tm.tm_min, tm.tm_min,
tm.tm_sec); 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) { if (logfd) {
char *msg; char *msg;
@ -90,13 +97,6 @@ void logmsg(int loglevel, const char *fmt, ...) {
ASPRINTF(&msg, "%s %s\n", stamp, buf); ASPRINTF(&msg, "%s %s\n", stamp, buf);
ckmsgq_add(global_ckp->logger, msg); 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); free(buf);
} }
} }

Loading…
Cancel
Save