summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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], \