From 6891ac08ee03f8b14f2605e1c3113d5b350ed6cc Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Tue, 19 Jun 2012 14:00:10 +1000 Subject: [PATCH] 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 --- servlog.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/servlog.c b/servlog.c index 01a7a3d4..091d782d 100644 --- a/servlog.c +++ b/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; }