From 13392414b113e9ac21d7abb008f62f3338ff41a0 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 19 May 2007 14:01:02 +1000 Subject: [PATCH] nicer date formatting (This used to be ctdb commit 78c256caa738593e335de65df752ff015f3a38e1) --- ctdb/lib/util/debug.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ctdb/lib/util/debug.c b/ctdb/lib/util/debug.c index a048ed807ed..7d1395480d4 100644 --- a/ctdb/lib/util/debug.c +++ b/ctdb/lib/util/debug.c @@ -25,17 +25,22 @@ void do_debug(const char *format, ...) { - struct timeval tm; + struct timeval t; va_list ap; char *s = NULL; + struct tm *tm; + char tbuf[100]; va_start(ap, format); vasprintf(&s, format, ap); va_end(ap); - gettimeofday(&tm, NULL); - printf("%-8.8d.%-6.6d [%d]: %s", (int)tm.tv_sec, (int)tm.tv_usec, - (int)getpid(), s); + t = timeval_current(); + tm = localtime(&t.tv_sec); + + strftime(tbuf,sizeof(tbuf)-1,"%Y/%m/%d %H:%M:%S", tm); + + printf("%s.%06u [%5u]: %s", tbuf, (unsigned)t.tv_usec, (unsigned)getpid(), s); fflush(stdout); free(s); } -- 2.47.3