summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 df2ba6931..d91c61a09 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 b116a66a8..7e9c182f0 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); \