From: Andrew Tridgell Date: Sat, 19 May 2007 04:01:02 +0000 (+1000) Subject: nicer date formatting X-Git-Tag: tevent-0.9.20~348^2~2707 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=13392414b113e9ac21d7abb008f62f3338ff41a0;p=thirdparty%2Fsamba.git nicer date formatting (This used to be ctdb commit 78c256caa738593e335de65df752ff015f3a38e1) --- 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); }