Rev 324: nicer date formatting in http://samba.org/~tridge/ctdb
tridge at samba.org
tridge at samba.org
Sat May 19 04:01:03 GMT 2007
------------------------------------------------------------
revno: 324
revision-id: tridge at samba.org-20070519040102-fo2l751oby7bd8gr
parent: tridge at samba.org-20070519034524-ly1k7rzoi42sdpe1
committer: Andrew Tridgell <tridge at samba.org>
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);
}
More information about the samba-cvs
mailing list