summaryrefslogtreecommitdiff
path: root/server/util
diff options
context:
space:
mode:
Diffstat (limited to 'server/util')
-rw-r--r--server/util/debug.c9
-rw-r--r--server/util/server.c12
-rw-r--r--server/util/util.h15
3 files changed, 32 insertions, 4 deletions
diff --git a/server/util/debug.c b/server/util/debug.c
index 24dcdb1d..814aec1e 100644
--- a/server/util/debug.c
+++ b/server/util/debug.c
@@ -7,6 +7,7 @@
const char *debug_prg_name = "sssd";
int debug_level = 0;
+int debug_timestamps = 0;
void debug_fn(const char *format, ...)
{
@@ -58,7 +59,13 @@ void ldb_debug_messages(void *context, enum ldb_debug_level level,
}
if (loglevel <= debug_level) {
- debug_fn("[%s] [ldb] (%d): %s\n", debug_prg_name, loglevel, message);
+ if (debug_timestamps) {
+ debug_fn("(%010ld) [%s] [ldb] (%d): %s\n",
+ (long)time(NULL), debug_prg_name, loglevel, message);
+ } else {
+ debug_fn("[%s] [ldb] (%d): %s\n",
+ debug_prg_name, loglevel, message);
+ }
}
free(message);
}
diff --git a/server/util/server.c b/server/util/server.c
index 4dfd18ef..fd6e4cdc 100644
--- a/server/util/server.c
+++ b/server/util/server.c
@@ -253,6 +253,7 @@ int server_setup(const char *name, int flags,
uint16_t stdin_event_flags;
char *conf_db;
int ret = EOK;
+ bool dt;
debug_prg_name = strdup(name);
if (!debug_prg_name) {
@@ -324,6 +325,17 @@ int server_setup(const char *name, int flags,
return ret;
}
+ /* same for debug timestamps */
+ dt = (debug_timestamps != 0);
+ ret = confdb_get_bool(ctx->confdb_ctx, ctx, conf_entry,
+ "debug-timestamps", dt, &dt);
+ if (ret != EOK) {
+ DEBUG(0, ("Error reading from confdb (%d) [%s]\n",
+ ret, strerror(ret)));
+ return ret;
+ }
+ if (dt) debug_timestamps = 1;
+
if (flags & FLAGS_INTERACTIVE) {
/* terminate when stdin goes away */
stdin_event_flags = TEVENT_FD_READ;
diff --git a/server/util/util.h b/server/util/util.h
index fac3ea54..02916c19 100644
--- a/server/util/util.h
+++ b/server/util/util.h
@@ -8,6 +8,7 @@
#include <string.h>
#include <errno.h>
#include <limits.h>
+#include <time.h>
#include "config.h"
#include "talloc.h"
#include "tevent.h"
@@ -15,11 +16,14 @@
extern const char *debug_prg_name;
extern int debug_level;
+extern int debug_timestamps;
void debug_fn(const char *format, ...);
#define SSSD_DEBUG_OPTS \
{"debug-level", 'd', POPT_ARG_INT, &debug_level, 0, \
- "Debug level", NULL},
+ "Debug level", NULL}, \
+ {"debug-timestamps", 0, POPT_ARG_NONE, &debug_timestamps, 0, \
+ "Add debug timestamps", NULL},
/** \def DEBUG(level, body)
\brief macro to generate debug messages
@@ -37,8 +41,13 @@ void debug_fn(const char *format, ...);
*/
#define DEBUG(level, body) do { \
if (level <= debug_level) { \
- debug_fn("[%s] [%s] (%d): ", \
- debug_prg_name, __FUNCTION__, level); \
+ if (debug_timestamps) { \
+ debug_fn("(%010ld) [%s] [%s] (%d): ", \
+ (long)time(NULL), debug_prg_name, __FUNCTION__, level); \
+ } else { \
+ debug_fn("[%s] [%s] (%d): ", \
+ debug_prg_name, __FUNCTION__, level); \
+ } \
debug_fn body; \
} \
} while(0);