summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Adam <obnox@redhat.com>2017-06-22 14:41:09 +0200
committerMichael Adam <obnox@redhat.com>2017-06-22 18:51:59 +0200
commita2dff3381ac1d14bd42d478a6c96216750009741 (patch)
tree475daeb1328eb780f72c917b8277572385853616
parentfd2732b97901f0025900509a59e79cd78c58393e (diff)
Don't let LOG segfault if log dir does not exist - fall back to stderr.
Change-Id: I65ad54381362280d9a5596e48aa3242f1160fd2d Signed-off-by: Michael Adam <obnox@redhat.com>
-rw-r--r--utils/utils.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/utils/utils.h b/utils/utils.h
index 17f9b49..1d82963 100644
--- a/utils/utils.h
+++ b/utils/utils.h
@@ -98,6 +98,12 @@ extern size_t logLevel;
fd = fopen (GFAPI_LOG_FILE, "a"); \
else \
fd = stderr; \
+ if (fd == NULL) { \
+ fprintf(stderr, "Error opening log file: %s\n" \
+ "Logging to stderr.\n", \
+ strerror(errno)); \
+ fd = stderr; \
+ } \
logTimeNow(timestamp, GB_TIME_STRING_BUFLEN); \
fprintf(fd, "[%s] %s: " fmt " [at %s+%d :<%s>]\n", \
timestamp, LogLevelLookup[level], \