summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/util/debug.c70
-rw-r--r--src/util/util.h21
2 files changed, 89 insertions, 2 deletions
diff --git a/src/util/debug.c b/src/util/debug.c
index 89b6217e..cca92eb9 100644
--- a/src/util/debug.c
+++ b/src/util/debug.c
@@ -58,6 +58,49 @@ errno_t set_debug_file_from_fd(const int fd)
return EOK;
}
+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)
+ return new_level;
+
+ if (old_level >= 1)
+ new_level |= SSSDBG_CRIT_FAILURE;
+
+ if (old_level >= 2)
+ new_level |= SSSDBG_OP_FAILURE;
+
+ if (old_level >= 3)
+ new_level |= SSSDBG_MINOR_FAILURE;
+
+ if (old_level >= 4)
+ new_level |= SSSDBG_CONF_SETTINGS;
+
+ if (old_level >= 5)
+ new_level |= SSSDBG_FUNC_DATA;
+
+ if (old_level >= 6)
+ new_level |= SSSDBG_TRACE_FUNC;
+
+ if (old_level >= 7)
+ new_level |= SSSDBG_TRACE_LIBS;
+
+ if (old_level >= 8)
+ new_level |= SSSDBG_TRACE_INTERNAL;
+
+ if (old_level >= 9)
+ new_level |= SSSDBG_TRACE_ALL;
+
+ return new_level;
+}
+
void debug_fn(const char *format, ...)
{
va_list ap;
@@ -70,6 +113,33 @@ void debug_fn(const char *format, ...)
va_end(ap);
}
+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;
+
+ int levels[] = {
+ SSSDBG_FATAL_FAILURE, /* 0 */
+ SSSDBG_CRIT_FAILURE,
+ SSSDBG_OP_FAILURE,
+ SSSDBG_MINOR_FAILURE,
+ SSSDBG_CONF_SETTINGS,
+ SSSDBG_FUNC_DATA,
+ SSSDBG_TRACE_FUNC,
+ SSSDBG_TRACE_LIBS,
+ SSSDBG_TRACE_INTERNAL,
+ SSSDBG_TRACE_ALL /* 9 */
+ };
+
+ return levels[old_level];
+}
+
void ldb_debug_messages(void *context, enum ldb_debug_level level,
const char *fmt, va_list ap)
{
diff --git a/src/util/util.h b/src/util/util.h
index 3ff5f629..acaaf4da 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -57,10 +57,27 @@ extern int debug_timestamps;
extern int debug_to_file;
extern const char *debug_log_file;
void debug_fn(const char *format, ...);
+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 0
-#define SSS_UNRESOLVED_DEBUG_LEVEL -1
+#define SSS_DEFAULT_DEBUG_LEVEL SSSDBG_DEFAULT
+#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 */
+#define SSSDBG_MINOR_FAILURE 0x0080 /* level 3 */
+#define SSSDBG_CONF_SETTINGS 0x0100 /* level 4 */
+#define SSSDBG_FUNC_DATA 0x0200 /* level 5 */
+#define SSSDBG_TRACE_FUNC 0x0400 /* level 6 */
+#define SSSDBG_TRACE_LIBS 0x1000 /* level 7 */
+#define SSSDBG_TRACE_INTERNAL 0x2000 /* level 8 */
+#define SSSDBG_TRACE_ALL 0x4000 /* level 9 */
+
+#define SSSDBG_UNRESOLVED -1
+#define SSSDBG_MASK_ALL 0xFFF0 /* enable all debug levels */
+#define SSSDBG_DEFAULT SSSDBG_FATAL_FAILURE
#define SSSDBG_TIMESTAMP_UNRESOLVED -1
#define SSSDBG_TIMESTAMP_DEFAULT 1