Skip to content

Commit bad229a

Browse files
jeffhostetlergitster
authored andcommitted
trace2: clarify UTC datetime formatting
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 26c6f25 commit bad229a

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

Documentation/technical/api-trace2.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@ git version 2.20.1.155.g426c96fcdb
7878
+
7979
------------
8080
$ cat ~/log.event
81-
{"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"}
82-
{"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"]}
83-
{"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"}
84-
{"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}
85-
{"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}
81+
{"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"}
82+
{"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"]}
83+
{"event":"cmd_name","sid":"1547659722619736-11614","thread":"main","time":"2019-01-16T17:28:42.621122Z","file":"git.c","line":432,"name":"version","hierarchy":"version"}
84+
{"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}
85+
{"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}
8686
------------
8787

8888
== Enabling a Target
@@ -542,7 +542,7 @@ The following key/value pairs are common to all events:
542542
"event":"version",
543543
"sid":"1547659722619736-11614",
544544
"thread":"main",
545-
"time":"2019-01-16 17:28:42.620713",
545+
"time":"2019-01-16T17:28:42.620713Z",
546546
"file":"common-main.c",
547547
"line":38,
548548
...

trace2/tr2_tbuf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ void tr2_tbuf_local_time(struct tr2_tbuf *tb)
1515
tm.tm_min, tm.tm_sec, (long)tv.tv_usec);
1616
}
1717

18-
void tr2_tbuf_utc_time(struct tr2_tbuf *tb)
18+
void tr2_tbuf_utc_datetime_extended(struct tr2_tbuf *tb)
1919
{
2020
struct timeval tv;
2121
struct tm tm;
@@ -26,7 +26,7 @@ void tr2_tbuf_utc_time(struct tr2_tbuf *tb)
2626
gmtime_r(&secs, &tm);
2727

2828
xsnprintf(tb->buf, sizeof(tb->buf),
29-
"%4d-%02d-%02d %02d:%02d:%02d.%06ld", tm.tm_year + 1900,
29+
"%4d-%02d-%02dT%02d:%02d:%02d.%06ldZ", tm.tm_year + 1900,
3030
tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec,
3131
(long)tv.tv_usec);
3232
}

trace2/tr2_tbuf.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ struct tr2_tbuf {
1616
void tr2_tbuf_local_time(struct tr2_tbuf *tb);
1717

1818
/*
19-
* Fill buffer with formatted UTC time string.
19+
* Fill buffer with formatted UTC datatime string.
2020
*/
21-
void tr2_tbuf_utc_time(struct tr2_tbuf *tb);
21+
void tr2_tbuf_utc_datetime_extended(struct tr2_tbuf *tb);
2222

2323
#endif /* TR2_TBUF_H */

trace2/tr2_tgt_event.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ static void event_fmt_prepare(const char *event_name, const char *file,
9494
*/
9595
if (!tr2env_event_be_brief || !strcmp(event_name, "version") ||
9696
!strcmp(event_name, "atexit")) {
97-
tr2_tbuf_utc_time(&tb_now);
97+
tr2_tbuf_utc_datetime_extended(&tb_now);
9898
jw_object_string(jw, "time", tb_now.buf);
9999
}
100100

0 commit comments

Comments
 (0)