From 7d26a47895168836529d22ebae94a3927c7c18c2 Mon Sep 17 00:00:00 2001 From: Michael Poole Date: Sun, 20 Sep 2009 20:45:08 -0400 Subject: [PATCH] Fix database failure reporting before the config file is first read. src/recdb.c (explain_failure): When MAIN_LOG is NULL, report to stderr. --- src/recdb.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/recdb.c b/src/recdb.c index 262de7f..8f4e8c5 100644 --- a/src/recdb.c +++ b/src/recdb.c @@ -568,9 +568,16 @@ failure_reason(int code) void explain_failure(RECDB *recdb, int code) { - log_module(MAIN_LOG, LOG_ERROR, "%s (got '%c') at %s line %d column %d.", - failure_reason(code), code & 255, - recdb->source, recdb->ctx.line, recdb->ctx.col); + static char msg[1024]; + snprintf(msg, sizeof(msg), "%s (got '%c') at %s line %d column %d.", + failure_reason(code), code & 255, + recdb->source, recdb->ctx.line, recdb->ctx.col); + if (MAIN_LOG == NULL) { + fputs(msg, stderr); + fputc('\n', stderr); + fflush(stderr); + } else + log_module(MAIN_LOG, LOG_ERROR, "%s", msg); } const char * -- 2.20.1