From 99dd40a885ed3d42af4bbbde7ee2fc98830544d0 Mon Sep 17 00:00:00 2001 From: Pavel Březina Date: Tue, 9 Aug 2011 13:01:05 +0200 Subject: New DEBUG facility - conversion https://fedorahosted.org/sssd/ticket/925 Conversion of the old debug_level format to the new one. (only where it was necessary) Removed: SSS_DEFAULT_DEBUG_LEVEL (completely replaced with SSSDBG_DEFAULT) --- src/util/debug.c | 27 ++++++++------------------- src/util/server.c | 4 +++- src/util/util.h | 1 - 3 files changed, 11 insertions(+), 21 deletions(-) (limited to 'src/util') diff --git a/src/util/debug.c b/src/util/debug.c index cca92eb93..e7ae83860 100644 --- a/src/util/debug.c +++ b/src/util/debug.c @@ -33,7 +33,7 @@ const char *debug_prg_name = "sssd"; -int debug_level = SSS_UNRESOLVED_DEBUG_LEVEL; +int debug_level = SSSDBG_UNRESOLVED; int debug_timestamps = SSSDBG_TIMESTAMP_UNRESOLVED; int debug_to_file = 0; @@ -143,22 +143,22 @@ int debug_get_level(int old_level) void ldb_debug_messages(void *context, enum ldb_debug_level level, const char *fmt, va_list ap) { - int loglevel = -1; + int loglevel = SSSDBG_UNRESOLVED; int ret; char * message = NULL; switch(level) { case LDB_DEBUG_FATAL: - loglevel = 0; + loglevel = SSSDBG_FATAL_FAILURE; break; case LDB_DEBUG_ERROR: - loglevel = 1; + loglevel = SSSDBG_CRIT_FAILURE; break; case LDB_DEBUG_WARNING: - loglevel = 6; + loglevel = SSSDBG_TRACE_FUNC; break; case LDB_DEBUG_TRACE: - loglevel = 9; + loglevel = SSSDBG_TRACE_ALL; break; } @@ -168,19 +168,8 @@ void ldb_debug_messages(void *context, enum ldb_debug_level level, return; } - if (loglevel <= debug_level) { - if (debug_timestamps) { - 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); - } - } + DEBUG_MSG(loglevel, "ldb", message); + free(message); } diff --git a/src/util/server.c b/src/util/server.c index 7d16d0484..38b1bacae 100644 --- a/src/util/server.c +++ b/src/util/server.c @@ -463,13 +463,15 @@ int server_setup(const char *name, int flags, /* set debug level if any in conf_entry */ ret = confdb_get_int(ctx->confdb_ctx, ctx, conf_entry, CONFDB_SERVICE_DEBUG_LEVEL, - SSS_DEFAULT_DEBUG_LEVEL, + SSSDBG_DEFAULT, &debug_level); if (ret != EOK) { DEBUG(0, ("Error reading from confdb (%d) [%s]\n", ret, strerror(ret))); return ret; } + + debug_level = debug_convert_old_level(debug_level); } /* same for debug timestamps */ diff --git a/src/util/util.h b/src/util/util.h index f1f1c634e..22b0937d7 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -61,7 +61,6 @@ int debug_get_level(int old_level); int debug_convert_old_level(int old_level); errno_t set_debug_file_from_fd(const int fd); -#define SSS_DEFAULT_DEBUG_LEVEL SSSDBG_DEFAULT #define SSS_UNRESOLVED_DEBUG_LEVEL SSSDBG_UNRESOLVED #define SSSDBG_FATAL_FAILURE 0x0010 /* level 0 */ -- cgit