More thread-safety to log_trace
This commit is contained in:
12
log_trace.c
12
log_trace.c
@@ -27,6 +27,7 @@ void log_ssl()
|
||||
void log_trace(LOG_LEVEL lvl, char *fmt, ... )
|
||||
{
|
||||
LOG_LEVEL cur_lvl = conf.rmps.loglevel - '0';
|
||||
char fmt_with_pfx[1024];
|
||||
|
||||
if (conf.isvalid)
|
||||
pthread_once(&once, open_logs);
|
||||
@@ -48,19 +49,20 @@ void log_trace(LOG_LEVEL lvl, char *fmt, ... )
|
||||
conf.rmps.errlog );
|
||||
fd = stderr;
|
||||
}
|
||||
fprintf( fd,
|
||||
"[%d-%02d-%02d %02d:%02d:%02d] %s: ",
|
||||
snprintf( fmt_with_pfx,
|
||||
sizeof(fmt_with_pfx),
|
||||
"[%d-%02d-%02d %02d:%02d:%02d] %s: %s\n",
|
||||
tm.tm_year + 1900,
|
||||
tm.tm_mon + 1,
|
||||
tm.tm_mday,
|
||||
tm.tm_hour,
|
||||
tm.tm_min,
|
||||
tm.tm_sec,
|
||||
prefixes[lvl-1] );
|
||||
prefixes[lvl-1],
|
||||
fmt );
|
||||
|
||||
va_start(list, fmt);
|
||||
vfprintf(fd, fmt, list);
|
||||
fprintf(fd, "\n");
|
||||
vfprintf(fd, fmt_with_pfx, list);
|
||||
fflush(fd);
|
||||
va_end(list);
|
||||
} else
|
||||
|
||||
Reference in New Issue
Block a user