]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
nicer date formatting
authorAndrew Tridgell <tridge@samba.org>
Sat, 19 May 2007 04:01:02 +0000 (14:01 +1000)
committerAndrew Tridgell <tridge@samba.org>
Sat, 19 May 2007 04:01:02 +0000 (14:01 +1000)
(This used to be ctdb commit 78c256caa738593e335de65df752ff015f3a38e1)

ctdb/lib/util/debug.c

index a048ed807ed02b4ac0ef9b680a12866e251d534f..7d1395480d4ee42f4e468c1a1ef15ff53a9c2af5 100644 (file)
 
 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);
 }