From 05315b44feaa9819e62f18477f2c6d20914eb7ce Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Fri, 25 Sep 2009 13:20:13 +0200 Subject: Send debug messages to logfile Introduces a new option --debug-to-files which makes SSSD output its debug information to a file instead of stderr, which is still the default. Also introduces a new confdb option debug_to_files which does the same, but can be specified per-service in the config file. The logfiles are stored in /var/log/sssd by default. Changes the initscript to log to files by default. --- server/util/server.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'server/util/server.c') diff --git a/server/util/server.c b/server/util/server.c index a8c502409..e8daf87cb 100644 --- a/server/util/server.c +++ b/server/util/server.c @@ -298,6 +298,7 @@ int server_setup(const char *name, int flags, char *conf_db; int ret = EOK; bool dt; + bool dl; debug_prg_name = strdup(name); if (!debug_prg_name) { @@ -352,7 +353,6 @@ int server_setup(const char *name, int flags, DEBUG(0,("Out of memory, aborting!\n")); return ENOMEM; } - DEBUG(3, ("CONFDB: %s\n", conf_db)); ret = confdb_init(ctx, &ctx->confdb_ctx, conf_db); if (ret != EOK) { @@ -382,6 +382,30 @@ int server_setup(const char *name, int flags, } if (dt) debug_timestamps = 1; + /* same for debug to file */ + dl = (debug_to_file != 0); + ret = confdb_get_bool(ctx->confdb_ctx, ctx, conf_entry, + CONFDB_SERVICE_DEBUG_TO_FILES, + dl, &dl); + if (ret != EOK) { + DEBUG(0, ("Error reading from confdb (%d) [%s]\n", + ret, strerror(ret))); + return ret; + } + if (dl) debug_to_file = 1; + + /* open log file if told so */ + if (debug_to_file) { + ret = open_debug_file(); + if (ret != EOK) { + DEBUG(0, ("Error setting up logging (%d) [%s]\n", + ret, strerror(ret))); + return ret; + } + } + + DEBUG(3, ("CONFDB: %s\n", conf_db)); + if (flags & FLAGS_INTERACTIVE) { /* terminate when stdin goes away */ stdin_event_flags = TEVENT_FD_READ; -- cgit