1
0
mirror of https://github.com/moparisthebest/curl synced 2024-08-13 17:03:50 -04:00

utilize the whole usec in the log and don't output to stderr if the logfile

can't be opened
This commit is contained in:
Daniel Stenberg 2005-05-25 12:04:52 +00:00
parent d55d3c2fd0
commit 3e79693e3b

View File

@ -81,20 +81,19 @@ void logmsg(const char *msg, ...)
struct tm *now = struct tm *now =
localtime(&tv.tv_sec); /* not multithread safe but we don't care */ localtime(&tv.tv_sec); /* not multithread safe but we don't care */
char timebuf[12]; char timebuf[20];
snprintf(timebuf, sizeof(timebuf), "%02d:%02d:%02d.%02ld", snprintf(timebuf, sizeof(timebuf), "%02d:%02d:%02d.%06ld",
now->tm_hour, now->tm_min, now->tm_sec, now->tm_hour, now->tm_min, now->tm_sec, tv.tv_usec);
tv.tv_usec/10000);
va_start(ap, msg); va_start(ap, msg);
vsprintf(buffer, msg, ap); vsprintf(buffer, msg, ap);
va_end(ap); va_end(ap);
logfp = fopen(serverlogfile, "a"); logfp = fopen(serverlogfile, "a");
fprintf(logfp?logfp:stderr, /* write to stderr if the logfile doesn't open */ if(logfp) {
"%s %s\n", timebuf, buffer); fprintf(logfp, "%s %s\n", timebuf, buffer);
if(logfp)
fclose(logfp); fclose(logfp);
}
} }
#if defined(WIN32) && !defined(__CYGWIN__) #if defined(WIN32) && !defined(__CYGWIN__)