diff --git a/src/log.c b/src/log.c index 5e1c35eb..c258b19b 100644 --- a/src/log.c +++ b/src/log.c @@ -87,12 +87,13 @@ void add_loglevel(const char *level) { * */ void vlog(char *fmt, va_list args) { - char timebuf[64]; + static char timebuf[64]; + static struct tm result; /* Get current time */ time_t t = time(NULL); /* Convert time to local time (determined by the locale) */ - struct tm *tmp = localtime(&t); + struct tm *tmp = localtime_r(&t, &result); /* Generate time prefix */ strftime(timebuf, sizeof(timebuf), "%x %X - ", tmp); #ifdef DEBUG_TIMING