summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimo Sorce <ssorce@redhat.com>2009-07-14 17:01:26 -0400
committerSimo Sorce <ssorce@redhat.com>2009-07-20 14:37:35 -0400
commit6c1d176dc9ad42d14727778248ec68628cb4daa1 (patch)
tree92b0474c2ad65eb09d7676563f3da1ff971e7d32
parentbb4570d2f3ed0c9b780010623de82c4c76d15a2c (diff)
downloadsssd-6c1d176dc9ad42d14727778248ec68628cb4daa1.tar.gz
sssd-6c1d176dc9ad42d14727778248ec68628cb4daa1.tar.xz
sssd-6c1d176dc9ad42d14727778248ec68628cb4daa1.zip
Add option to add timestamps to debug output
use '--debug-timestamps' at the command line or set 'debug-timestamps = TRUE' in the configuration file.
-rw-r--r--server/monitor/monitor.c11
-rw-r--r--server/util/debug.c9
-rw-r--r--server/util/server.c12
-rw-r--r--server/util/util.h15
4 files changed, 39 insertions, 8 deletions
diff --git a/server/monitor/monitor.c b/server/monitor/monitor.c
index 11c35d0fd..269fcbf5e 100644
--- a/server/monitor/monitor.c
+++ b/server/monitor/monitor.c
@@ -763,9 +763,11 @@ static int get_service_config(struct mt_ctx *ctx, const char *name,
}
if (!svc->command) {
- svc->command = talloc_asprintf(svc, "%s/sssd_%s -d %d",
- SSSD_LIBEXEC_PATH, svc->name,
- debug_level);
+ svc->command = talloc_asprintf(svc, "%s/sssd_%s -d %d%s",
+ SSSD_LIBEXEC_PATH,
+ svc->name, debug_level,
+ (debug_timestamps?
+ " --debug-timestamps":""));
if (!svc->command) {
talloc_free(svc);
return ENOMEM;
@@ -870,8 +872,9 @@ static int get_provider_config(struct mt_ctx *ctx, const char *name,
/* if there are no custom commands, build a default one */
if (!svc->command) {
svc->command = talloc_asprintf(svc,
- "%s/sssd_be -d %d --provider %s --domain %s",
+ "%s/sssd_be -d %d%s --provider %s --domain %s",
SSSD_LIBEXEC_PATH, debug_level,
+ (debug_timestamps?" --debug-timestamps":""),
svc->provider, svc->name);
if (!svc->command) {
talloc_free(svc);
diff --git a/server/util/debug.c b/server/util/debug.c
index 24dcdb1d9..814aec1e1 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 4dfd18ef1..fd6e4cdc4 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 fac3ea549..02916c191 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);