From 9797bd197d48ca17a124c245295937ac3d48ab58 Mon Sep 17 00:00:00 2001 From: "Kaleb S. KEITHLEY" Date: Mon, 16 Jun 2014 12:29:03 -0400 Subject: core: use gf_time_fmt() instead of localtime()+strftime() gf_time_fmt() has existed since 3.3; it provides consistent timestamps (i.e. UTC times) throughout the implementation. (BTW, the other name for UTC is GMT.) N.B. many (all?) commercial storage solutions use UTC time for logging. This makes for easier debugging across geographically distributed systems. Also adding a "%s" fmt for portably printing time as simple numeric value on systems regardless of whether 32-bit or 64-bit time_t. Plus a minor tweak to return a ptr to the dest-string to allow gf_time_fmt() to be passed as a param in a *printf(). Someday we should pick the "one true" timestamp format and revise all calls to gf_time_fmt() to use it instead of the five or six different formats. Change-Id: I78202ae14b7246fa424efeea56bf2463e14abfb0 BUG: 1109917 Signed-off-by: Kaleb S. KEITHLEY Reviewed-on: http://review.gluster.org/8085 Tested-by: Gluster Build System Reviewed-by: Niels de Vos Reviewed-by: Vijay Bellur --- xlators/mount/fuse/src/fuse-bridge.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'xlators/mount/fuse/src') diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c index 380093a9a7a..6290d0a783f 100644 --- a/xlators/mount/fuse/src/fuse-bridge.c +++ b/xlators/mount/fuse/src/fuse-bridge.c @@ -5003,21 +5003,15 @@ out: int dump_history_fuse (circular_buffer_t *cb, void *data) { - char *string = NULL; - struct tm *tm = NULL; char timestr[256] = {0,}; - string = (char *)cb->data; - tm = localtime (&cb->tv.tv_sec); + gf_time_fmt (timestr, sizeof timestr, cb->tv.tv_sec, gf_timefmt_F_HMS); - if (tm) { - strftime (timestr, 256, "%Y-%m-%d %H:%M:%S", tm); - snprintf (timestr + strlen (timestr), 256 - strlen (timestr), - ".%"GF_PRI_SUSECONDS, cb->tv.tv_usec); - gf_proc_dump_write ("TIME", "%s", timestr); - } + snprintf (timestr + strlen (timestr), 256 - strlen (timestr), + ".%"GF_PRI_SUSECONDS, cb->tv.tv_usec); + gf_proc_dump_write ("TIME", "%s", timestr); - gf_proc_dump_write ("message", "%s\n", string); + gf_proc_dump_write ("message", "%s\n", cb->data); return 0; } -- cgit