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 const char* timestamp(struct timeval *tp) {
|
||||||
static char ts[80];
|
static char ts[80];
|
||||||
int hh, mm, ss;
|
int year, month, day;
|
||||||
|
int hour, min, sec, usec;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
struct tm *time;
|
struct tm *time;
|
||||||
if (tp)
|
if (tp)
|
||||||
@@ -235,10 +236,15 @@ static const char* timestamp(struct timeval *tp) {
|
|||||||
else
|
else
|
||||||
gettimeofday(&tv, NULL);
|
gettimeofday(&tv, NULL);
|
||||||
time = localtime(&tv.tv_sec);
|
time = localtime(&tv.tv_sec);
|
||||||
hh = time->tm_hour;
|
year = 1900 + time->tm_year;
|
||||||
mm = time->tm_min;
|
month = time->tm_mon + 1;
|
||||||
ss = time->tm_sec;
|
day = time->tm_mday;
|
||||||
snprintf(ts, 80, "%02d:%02d:%02d.%06d", hh, mm, ss, (int) tv.tv_usec);
|
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;
|
return ts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user