]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
Add timezone to timestamp in JSON logs
authorAlexander Gozman <a.gozman@securitycode.ru>
Thu, 7 May 2015 09:40:28 +0000 (12:40 +0300)
committerVictor Julien <victor@inliniac.net>
Thu, 7 May 2015 09:46:32 +0000 (11:46 +0200)
src/util-time.c

index 1e4237335d522b73b3bd42334ba195d21ed995b9..7c7a362458bbc8214f83b440e11dd3b54171b296 100644 (file)
@@ -128,11 +128,11 @@ void CreateIsoTimeString (const struct timeval *ts, char *str, size_t size)
     time_t time = ts->tv_sec;
     struct tm local_tm;
     struct tm *t = (struct tm*)SCLocalTime(time, &local_tm);
+    char time_fmt[64] = { 0 };
 
     if (likely(t != NULL)) {
-        snprintf(str, size, "%04d-%02d-%02dT%02d:%02d:%02d.%06u",
-                t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour,
-                t->tm_min, t->tm_sec, (uint32_t) ts->tv_usec);
+        strftime(time_fmt, sizeof(time_fmt), "%Y-%m-%dT%H:%M:%S.%%06u%z", t);
+        snprintf(str, size, time_fmt, ts->tv_usec);
     } else {
         snprintf(str, size, "ts-error");
     }