From: Wilfried Goesgens Date: Wed, 13 Oct 2010 19:51:27 +0000 (+0200) Subject: * vCtdlLogPrintf(): combine the server data plus the application format string into... X-Git-Tag: v8.01~660 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=fb181fc0c1be1f3f05e7891e635c2ad5503b3abc * vCtdlLogPrintf(): combine the server data plus the application format string into a new format string we then process with va_args. -> still no strbuf needed -> no problems with race conditions causing clashes between several lines --- diff --git a/citadel/sysdep.c b/citadel/sysdep.c index 10a955a60..2e43b66bb 100644 --- a/citadel/sysdep.c +++ b/citadel/sysdep.c @@ -140,27 +140,30 @@ void vCtdlLogPrintf(enum LogLevel loglevel, const char *format, va_list arg_ptr) unixtime = tv.tv_sec; localtime_r(&unixtime, &tim); - fprintf(stderr, - "%04d/%02d/%02d %2d:%02d:%02d.%06ld ", - tim.tm_year + 1900, tim.tm_mon + 1, - tim.tm_mday, tim.tm_hour, tim.tm_min, - tim.tm_sec, (long)tv.tv_usec - ); - + *LWP = '\0'; if (lwpid != 0) { - fprintf(stderr, "[LWP:%ld] ", lwpid); + snprintf(LWP, 64, "[LWP:%ld] ", lwpid); } + *SESS = '\0'; if (CCC != NULL) { if (CCC->cs_pid != 0) { - fprintf(stderr, "[%3d] ", CCC->cs_pid); + snprintf(SESS, 64, " [%3d] ", CCC->cs_pid); } else if (CCC->user.usernum != 0) { - fprintf(stderr, "[:%ld] ", CCC->user.usernum); + snprintf(SESS, 64, " [:%ld] ", CCC->user.usernum); } } - vfprintf(stderr, format, arg_ptr); + snprintf(formatbuf, SIZ, + "%04d/%02d/%02d %2d:%02d:%02d.%06ld %s%s%s", + tim.tm_year + 1900, tim.tm_mon + 1, + tim.tm_mday, tim.tm_hour, tim.tm_min, + tim.tm_sec, (long)tv.tv_usec, + LWP, SESS, format + ); + + vfprintf(stderr, formatbuf, arg_ptr); fflush(stderr); } }