Fixed bug report #2958074 indicating

(http://curl.haxx.se/bug/view.cgi?id=2958074) that curl on Windows with
option --trace-time did not use local time when timestamping trace lines.
This could also happen on other systems depending on time souurce.
This commit is contained in:
Yang Tse
2010-02-25 06:59:04 +00:00
parent e25c5283d8
commit 6a8aa246ff
4 changed files with 27 additions and 12 deletions

View File

@@ -72,6 +72,8 @@ void logmsg(const char *msg, ...)
time_t sec;
struct tm *now;
char timebuf[20];
static time_t epoch_offset;
static int known_offset;
if (!serverlogfile) {
fprintf(stderr, "Error: serverlogfile not set\n");
@@ -79,8 +81,12 @@ void logmsg(const char *msg, ...)
}
tv = curlx_tvnow();
sec = tv.tv_sec;
now = localtime(&sec); /* not multithread safe but we don't care */
if(!known_offset) {
epoch_offset = time(NULL) - tv.tv_sec;
known_offset = 1;
}
sec = epoch_offset + tv.tv_sec;
now = localtime(&sec); /* not thread safe but we don't care */
snprintf(timebuf, sizeof(timebuf), "%02d:%02d:%02d.%06ld",
(int)now->tm_hour, (int)now->tm_min, (int)now->tm_sec, (long)tv.tv_usec);