fixed logging errorx

This commit is contained in:
Amy G. Bowersox 2019-12-07 19:44:48 -07:00
parent 79bb9552da
commit 3cbcda0886

View File

@ -7,7 +7,7 @@
/* string equivalents to the severity values */ /* string equivalents to the severity values */
static const char *severities[] = { "FATAL", "ERROR", "WARN ", "INFO ", "DEBUG" }; static const char *severities[] = { "FATAL", "ERROR", "WARN ", "INFO ", "DEBUG" };
static FILE *logfile = stdout; /* log file pointer */ static FILE *logfile = NULL; /* log file pointer */
void Log(int level, const char *format, ...) void Log(int level, const char *format, ...)
{ {
@ -24,7 +24,7 @@ void Log(int level, const char *format, ...)
gettimeofday(&tv, NULL); gettimeofday(&tv, NULL);
localtime_r(&(tv.tv_sec), &tm); localtime_r(&(tv.tv_sec), &tm);
strftime(timestamp, 32, "%F %T", &tm); strftime(timestamp, 32, "%F %T", &tm);
fprintf(logfile, "%s.%06u %s %s\n", timestamp, tv.tv_usec, severities[level], buf); fprintf(logfile ? logfile : stdout, "%s.%06u %s %s\n", timestamp, tv.tv_usec, severities[level], buf);
} }
void Log_assert_failed(const char *test, const char *file, int line) void Log_assert_failed(const char *test, const char *file, int line)