------------------------------------------------------------
revno: 324
revision-id: [EMAIL PROTECTED]
parent: [EMAIL PROTECTED]
committer: Andrew Tridgell <[EMAIL PROTECTED]>
branch nick: tridge
timestamp: Sat 2007-05-19 14:01:02 +1000
message:
  nicer date formatting
modified:
  lib/util/debug.c               debug.c-20070417155854-2i3crb0irl716qft-1
=== modified file 'lib/util/debug.c'
--- a/lib/util/debug.c  2007-04-23 10:45:14 +0000
+++ b/lib/util/debug.c  2007-05-19 04:01:02 +0000
@@ -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);
 }

Reply via email to