Add the date to the start of message in the log
r3610 | dcl | 2012-06-19 14:00:10 +1000 (Tue, 19 Jun 2012) | 1 line
This commit is contained in:
16
servlog.c
16
servlog.c
@@ -227,7 +227,8 @@
|
||||
|
||||
static const char* timestamp(struct timeval *tp) {
|
||||
static char ts[80];
|
||||
int hh, mm, ss;
|
||||
int year, month, day;
|
||||
int hour, min, sec, usec;
|
||||
struct timeval tv;
|
||||
struct tm *time;
|
||||
if (tp)
|
||||
@@ -235,10 +236,15 @@ static const char* timestamp(struct timeval *tp) {
|
||||
else
|
||||
gettimeofday(&tv, NULL);
|
||||
time = localtime(&tv.tv_sec);
|
||||
hh = time->tm_hour;
|
||||
mm = time->tm_min;
|
||||
ss = time->tm_sec;
|
||||
snprintf(ts, 80, "%02d:%02d:%02d.%06d", hh, mm, ss, (int) tv.tv_usec);
|
||||
year = 1900 + time->tm_year;
|
||||
month = time->tm_mon + 1;
|
||||
day = time->tm_mday;
|
||||
hour = time->tm_hour;
|
||||
min = time->tm_min;
|
||||
sec = time->tm_sec;
|
||||
usec = (int) tv.tv_usec;
|
||||
snprintf(ts, 80, "%04d-%02d-%02dT%02d:%02d:%02d.%06d",
|
||||
year, month, day, hour, min, sec, usec);
|
||||
return ts;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user