trace2: clarify UTC datetime formatting
authorJeff Hostetler <jeffhost@microsoft.com>
Mon, 15 Apr 2019 20:39:48 +0000 (13:39 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 16 Apr 2019 04:37:07 +0000 (13:37 +0900)
Update tr2_tbuf_utc_datetime to generate extended UTC format.
Update tr2_tgt_event target to use extended format in 'time' columns.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/technical/api-trace2.txt
trace2/tr2_tbuf.c
trace2/tr2_tbuf.h
trace2/tr2_tgt_event.c
index baaa1153bb898a7b21208448ca93e29c6c7eaf21..cdc00bcc5d3439a0fb662409a4b64d655f8916e4 100644 (file)
@@ -78,11 +78,11 @@ git version 2.20.1.155.g426c96fcdb
 +
 ------------
 $ cat ~/log.event
-{"event":"version","sid":"1547659722619736-11614","thread":"main","time":"2019-01-16 17:28:42.620713","file":"common-main.c","line":38,"evt":"1","exe":"2.20.1.155.g426c96fcdb"}
-{"event":"start","sid":"1547659722619736-11614","thread":"main","time":"2019-01-16 17:28:42.621027","file":"common-main.c","line":39,"t_abs":0.001173,"argv":["git","version"]}
-{"event":"cmd_name","sid":"1547659722619736-11614","thread":"main","time":"2019-01-16 17:28:42.621122","file":"git.c","line":432,"name":"version","hierarchy":"version"}
-{"event":"exit","sid":"1547659722619736-11614","thread":"main","time":"2019-01-16 17:28:42.621236","file":"git.c","line":662,"t_abs":0.001227,"code":0}
-{"event":"atexit","sid":"1547659722619736-11614","thread":"main","time":"2019-01-16 17:28:42.621268","file":"trace2/tr2_tgt_event.c","line":163,"t_abs":0.001265,"code":0}
+{"event":"version","sid":"1547659722619736-11614","thread":"main","time":"2019-01-16T17:28:42.620713Z","file":"common-main.c","line":38,"evt":"1","exe":"2.20.1.155.g426c96fcdb"}
+{"event":"start","sid":"1547659722619736-11614","thread":"main","time":"2019-01-16T17:28:42.621027Z","file":"common-main.c","line":39,"t_abs":0.001173,"argv":["git","version"]}
+{"event":"cmd_name","sid":"1547659722619736-11614","thread":"main","time":"2019-01-16T17:28:42.621122Z","file":"git.c","line":432,"name":"version","hierarchy":"version"}
+{"event":"exit","sid":"1547659722619736-11614","thread":"main","time":"2019-01-16T17:28:42.621236Z","file":"git.c","line":662,"t_abs":0.001227,"code":0}
+{"event":"atexit","sid":"1547659722619736-11614","thread":"main","time":"2019-01-16T17:28:42.621268Z","file":"trace2/tr2_tgt_event.c","line":163,"t_abs":0.001265,"code":0}
 ------------
 
 == Enabling a Target
@@ -542,7 +542,7 @@ The following key/value pairs are common to all events:
        "event":"version",
        "sid":"1547659722619736-11614",
        "thread":"main",
-       "time":"2019-01-16 17:28:42.620713",
+       "time":"2019-01-16T17:28:42.620713Z",
        "file":"common-main.c",
        "line":38,
        ...
index 0844910423679374bcf418bf1abd79c8edddcbe7..eb1b240d8a273b05cda8da5ba7e1dbb64828cd1a 100644 (file)
@@ -15,7 +15,7 @@ void tr2_tbuf_local_time(struct tr2_tbuf *tb)
                  tm.tm_min, tm.tm_sec, (long)tv.tv_usec);
 }
 
-void tr2_tbuf_utc_time(struct tr2_tbuf *tb)
+void tr2_tbuf_utc_datetime_extended(struct tr2_tbuf *tb)
 {
        struct timeval tv;
        struct tm tm;
@@ -26,7 +26,7 @@ void tr2_tbuf_utc_time(struct tr2_tbuf *tb)
        gmtime_r(&secs, &tm);
 
        xsnprintf(tb->buf, sizeof(tb->buf),
-                 "%4d-%02d-%02d %02d:%02d:%02d.%06ld", tm.tm_year + 1900,
+                 "%4d-%02d-%02dT%02d:%02d:%02d.%06ldZ", tm.tm_year + 1900,
                  tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec,
                  (long)tv.tv_usec);
 }
index 9cdefa395749f02286c4f821d51bf78c6c06d181..2a1d173ff255fde994c0dea230d9235d661f75fb 100644 (file)
@@ -16,8 +16,8 @@ struct tr2_tbuf {
 void tr2_tbuf_local_time(struct tr2_tbuf *tb);
 
 /*
- * Fill buffer with formatted UTC time string.
+ * Fill buffer with formatted UTC datatime string.
  */
-void tr2_tbuf_utc_time(struct tr2_tbuf *tb);
+void tr2_tbuf_utc_datetime_extended(struct tr2_tbuf *tb);
 
 #endif /* TR2_TBUF_H */
index 48d9193b2cf2831d6d1902ad2c9c9fae851ba291..2c97cf54be95e28373fd66cb195f82f98509b6a5 100644 (file)
@@ -94,7 +94,7 @@ static void event_fmt_prepare(const char *event_name, const char *file,
         */
        if (!tr2env_event_be_brief || !strcmp(event_name, "version") ||
            !strcmp(event_name, "atexit")) {
-               tr2_tbuf_utc_time(&tb_now);
+               tr2_tbuf_utc_datetime_extended(&tb_now);
                jw_object_string(jw, "time", tb_now.buf);
        }