diff options
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/debug.c | 9 | ||||
-rw-r--r-- | src/util/server.c | 2 | ||||
-rw-r--r-- | src/util/util.h | 13 |
3 files changed, 11 insertions, 13 deletions
diff --git a/src/util/debug.c b/src/util/debug.c index e7ae83860..3a1b7ca2b 100644 --- a/src/util/debug.c +++ b/src/util/debug.c @@ -35,7 +35,6 @@ const char *debug_prg_name = "sssd"; int debug_level = SSSDBG_UNRESOLVED; int debug_timestamps = SSSDBG_TIMESTAMP_UNRESOLVED; - int debug_to_file = 0; const char *debug_log_file = "sssd"; FILE *debug_file = NULL; @@ -63,12 +62,9 @@ int debug_convert_old_level(int old_level) if ((old_level != 0) && !(old_level & 0x000F)) return old_level; - if( old_level == SSS_UNRESOLVED_DEBUG_LEVEL ) - return SSSDBG_UNRESOLVED; - int new_level = SSSDBG_FATAL_FAILURE; - if (old_level == 0) + if (old_level <= 0) return new_level; if (old_level >= 1) @@ -118,9 +114,6 @@ int debug_get_level(int old_level) if ((old_level != 0) && !(old_level & 0x000F)) return old_level; - if( old_level == SSS_UNRESOLVED_DEBUG_LEVEL ) - return SSSDBG_UNRESOLVED; - if ((old_level > 9) || (old_level < 0)) return SSSDBG_FATAL_FAILURE; diff --git a/src/util/server.c b/src/util/server.c index 38b1bacae..42fd93609 100644 --- a/src/util/server.c +++ b/src/util/server.c @@ -459,7 +459,7 @@ int server_setup(const char *name, int flags, return ret; } - if (debug_level == SSS_UNRESOLVED_DEBUG_LEVEL) { + if (debug_level == SSSDBG_UNRESOLVED) { /* set debug level if any in conf_entry */ ret = confdb_get_int(ctx->confdb_ctx, ctx, conf_entry, CONFDB_SERVICE_DEBUG_LEVEL, diff --git a/src/util/util.h b/src/util/util.h index 22b0937d7..c37cab8ab 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -61,8 +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_UNRESOLVED_DEBUG_LEVEL SSSDBG_UNRESOLVED - #define SSSDBG_FATAL_FAILURE 0x0010 /* level 0 */ #define SSSDBG_CRIT_FAILURE 0x0020 /* level 1 */ #define SSSDBG_OP_FAILURE 0x0040 /* level 2 */ @@ -74,7 +72,8 @@ errno_t set_debug_file_from_fd(const int fd); #define SSSDBG_TRACE_INTERNAL 0x2000 /* level 8 */ #define SSSDBG_TRACE_ALL 0x4000 /* level 9 */ -#define SSSDBG_UNRESOLVED -1 +#define SSSDBG_INVALID -1 +#define SSSDBG_UNRESOLVED 0 #define SSSDBG_MASK_ALL 0xFFF0 /* enable all debug levels */ #define SSSDBG_DEFAULT SSSDBG_FATAL_FAILURE @@ -153,7 +152,13 @@ errno_t set_debug_file_from_fd(const int fd); \param level the debug level, please use one of the SSSDBG*_ macros */ -#define DEBUG_IS_SET(level) ((debug_level > 0) && (debug_level & (level))) +#define DEBUG_IS_SET(level) (debug_level & (level)) + +#define CONVERT_AND_SET_DEBUG_LEVEL(new_value) debug_level = ( \ + ((new_value) != SSSDBG_INVALID) \ + ? debug_convert_old_level(new_value) \ + : SSSDBG_UNRESOLVED /* Debug level should be loaded from config file. */ \ +); #define PRINT(fmt, ...) fprintf(stdout, gettext(fmt), ##__VA_ARGS__) #define ERROR(fmt, ...) fprintf(stderr, gettext(fmt), ##__VA_ARGS__) |