diff options
author | Martin Schwenke <martin@meltin.net> | 2014-10-16 19:46:43 +1100 |
---|---|---|
committer | Amitay Isaacs <amitay@samba.org> | 2014-10-28 05:42:04 +0100 |
commit | 38c8e15690331c4798f9caf3be6a44251d3db809 (patch) | |
tree | c7dafa2062abef3d68756335235a167fb262f2b2 | |
parent | 739324eead1d8ece13151504c0a54ab5c82e51db (diff) | |
download | samba-38c8e15690331c4798f9caf3be6a44251d3db809.tar.gz samba-38c8e15690331c4798f9caf3be6a44251d3db809.tar.xz samba-38c8e15690331c4798f9caf3be6a44251d3db809.zip |
ctdb-logging: Simplify file logging timestamping with timeval_str_buf()
If nothing else, this is slightly more portable.
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
-rw-r--r-- | ctdb/server/ctdb_logging_file.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/ctdb/server/ctdb_logging_file.c b/ctdb/server/ctdb_logging_file.c index 09367f3488..28b72231d9 100644 --- a/ctdb/server/ctdb_logging_file.c +++ b/ctdb/server/ctdb_logging_file.c @@ -22,6 +22,7 @@ #include "../include/ctdb_private.h" #include "system/time.h" #include "system/filesys.h" +#include "lib/util/time_basic.h" struct file_state { int fd; @@ -34,19 +35,16 @@ static void ctdb_log_to_file(void *private_ptr, int dbglevel, const char *s) { struct file_state *state = talloc_get_type( private_ptr, struct file_state); - struct timeval t; - struct tm *tm; - char tbuf[100]; + struct timeval tv; + struct timeval_buf tvbuf; char *s2 = NULL; int ret; - t = timeval_current(); - tm = localtime(&t.tv_sec); + GetTimeOfDay(&tv); + timeval_str_buf(&tv, false, true, &tvbuf); - strftime(tbuf,sizeof(tbuf)-1,"%Y/%m/%d %H:%M:%S", tm); - - ret = asprintf(&s2, "%s.%06u [%s%5u]: %s\n", - tbuf, (unsigned)t.tv_usec, + ret = asprintf(&s2, "%s [%s%5u]: %s\n", + tvbuf.buf, debug_extra, (unsigned)getpid(), s); if (ret == -1) { const char *errstr = "asprintf failed\n"; |