summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2009-12-03 09:57:58 -0500
committerStephen Gallagher <sgallagh@redhat.com>2009-12-03 12:17:15 -0500
commit80bc946c83d630eae8e867d1a5960851836b0533 (patch)
tree647f8f5aecfceffd8ab9dd29d5eb62a97f9098de /server
parent068e7e9b945dd1c9c6bf20b191cb95af918836e0 (diff)
downloadsssd-80bc946c83d630eae8e867d1a5960851836b0533.tar.gz
sssd-80bc946c83d630eae8e867d1a5960851836b0533.tar.bz2
sssd-80bc946c83d630eae8e867d1a5960851836b0533.zip
Make debug log timestamps human-readable
Diffstat (limited to 'server')
-rw-r--r--server/util/debug.c9
-rw-r--r--server/util/util.h8
2 files changed, 13 insertions, 4 deletions
diff --git a/server/util/debug.c b/server/util/debug.c
index df2ba693..d91c61a0 100644
--- a/server/util/debug.c
+++ b/server/util/debug.c
@@ -26,6 +26,7 @@
#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/time.h>
#include "util/util.h"
@@ -95,8 +96,12 @@ void ldb_debug_messages(void *context, enum ldb_debug_level level,
if (loglevel <= debug_level) {
if (debug_timestamps) {
- debug_fn("(%010ld) [%s] [ldb] (%d): %s\n",
- (long)time(NULL), debug_prg_name, loglevel, message);
+ time_t rightnow = time(NULL);
+ char stamp[25];
+ memcpy(stamp, ctime(&rightnow), 24);
+ stamp[24] = '\0';
+ debug_fn("(%s) [%s] [ldb] (%d): %s\n",
+ stamp, debug_prg_name, loglevel, message);
} else {
debug_fn("[%s] [ldb] (%d): %s\n",
debug_prg_name, loglevel, message);
diff --git a/server/util/util.h b/server/util/util.h
index b116a66a..7e9c182f 100644
--- a/server/util/util.h
+++ b/server/util/util.h
@@ -80,8 +80,12 @@ errno_t set_debug_file_from_fd(const int fd);
#define DEBUG(level, body) do { \
if (level <= debug_level) { \
if (debug_timestamps) { \
- debug_fn("(%010ld) [%s] [%s] (%d): ", \
- (long)time(NULL), debug_prg_name, __FUNCTION__, level); \
+ time_t rightnow = time(NULL); \
+ char stamp[25]; \
+ memcpy(stamp, ctime(&rightnow), 24); \
+ stamp[24] = '\0'; \
+ debug_fn("(%s) [%s] [%s] (%d): ", \
+ stamp, debug_prg_name, __FUNCTION__, level); \
} else { \
debug_fn("[%s] [%s] (%d): ", \
debug_prg_name, __FUNCTION__, level); \