Blame SOURCES/0023-DEBUG-introduce-new-SSSDBG_TRACE_LDB-level.patch

836b22
From 902c8931f51d4ca17147901ff542a71d7c434f01 Mon Sep 17 00:00:00 2001
836b22
From: Alexey Tikhonov <atikhono@redhat.com>
836b22
Date: Tue, 5 May 2020 18:26:52 +0200
836b22
Subject: [PATCH 23/25] DEBUG: introduce new SSSDBG_TRACE_LDB level
836b22
MIME-Version: 1.0
836b22
Content-Type: text/plain; charset=UTF-8
836b22
Content-Transfer-Encoding: 8bit
836b22
836b22
libldb LDB_DEBUG_TRACE messages usually doesn't bring any useful info
836b22
but create a lot of unneeded noise in the logs.
836b22
Nonetheless it feels too radical to drop them completely.
836b22
This patch introduces new debug_level=10 (0x10000) especially for those
836b22
messages.
836b22
836b22
Reviewed-by: Pawel Polawski <ppolawsk@redhat.com>
836b22
(cherry picked from commit b5604d072e93bca7fc0c408fcfbb88f41c4d50ca)
836b22
836b22
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
836b22
836b22
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
836b22
---
836b22
 src/man/include/debug_levels.xml       |  5 +++
836b22
 src/man/include/debug_levels_tools.xml |  5 +++
836b22
 src/tests/debug-tests.c                | 49 ++++++++++++++++----------
836b22
 src/util/debug.c                       |  5 ++-
836b22
 src/util/debug.h                       |  7 +++-
836b22
 5 files changed, 51 insertions(+), 20 deletions(-)
836b22
836b22
diff --git a/src/man/include/debug_levels.xml b/src/man/include/debug_levels.xml
836b22
index 93a8ec901..b5e13ba3e 100644
836b22
--- a/src/man/include/debug_levels.xml
836b22
+++ b/src/man/include/debug_levels.xml
836b22
@@ -77,6 +77,11 @@
836b22
          <emphasis>9</emphasis>,
836b22
          <emphasis>0x4000</emphasis>: Extremely low-level tracing information.
836b22
     </para>
836b22
+    <para>
836b22
+         <emphasis>10</emphasis>,
836b22
+         <emphasis>0x10000</emphasis>: Even more low-level libldb tracing
836b22
+         information. Almost never really required.
836b22
+    </para>
836b22
     <para>
836b22
         To log required bitmask debug levels, simply add their numbers together
836b22
         as shown in following examples:
836b22
diff --git a/src/man/include/debug_levels_tools.xml b/src/man/include/debug_levels_tools.xml
836b22
index fcc0c2d8b..b592d50fc 100644
836b22
--- a/src/man/include/debug_levels_tools.xml
836b22
+++ b/src/man/include/debug_levels_tools.xml
836b22
@@ -58,6 +58,11 @@
836b22
          <emphasis>9</emphasis>,
836b22
          <emphasis>0x4000</emphasis>: Extremely low-level tracing information.
836b22
     </para>
836b22
+    <para>
836b22
+         <emphasis>10</emphasis>,
836b22
+         <emphasis>0x10000</emphasis>: Even more low-level libldb tracing
836b22
+         information. Almost never really required.
836b22
+    </para>
836b22
     <para>
836b22
         To log required bitmask debug levels, simply add their numbers together
836b22
         as shown in following examples:
836b22
diff --git a/src/tests/debug-tests.c b/src/tests/debug-tests.c
836b22
index 95b0a8f00..1e78f506e 100644
836b22
--- a/src/tests/debug-tests.c
836b22
+++ b/src/tests/debug-tests.c
836b22
@@ -48,10 +48,11 @@ START_TEST(test_debug_convert_old_level_old_format)
836b22
         SSSDBG_TRACE_FUNC,
836b22
         SSSDBG_TRACE_LIBS,
836b22
         SSSDBG_TRACE_INTERNAL,
836b22
-        SSSDBG_TRACE_ALL | SSSDBG_BE_FO
836b22
+        SSSDBG_TRACE_ALL | SSSDBG_BE_FO,
836b22
+        SSSDBG_TRACE_LDB
836b22
     };
836b22
 
836b22
-    for (old_level = 0; old_level <= 9; old_level++) {
836b22
+    for (old_level = 0; old_level < N_ELEMENTS(levels); old_level++) {
836b22
         expected_level |= levels[old_level];
836b22
 
836b22
         char *msg = NULL;
836b22
@@ -108,6 +109,10 @@ START_TEST(test_debug_convert_old_level_new_format)
836b22
         debug_convert_old_level(SSSDBG_TRACE_ALL) == SSSDBG_TRACE_ALL,
836b22
         "Invalid conversion of SSSDBG_TRACE_ALL"
836b22
     );
836b22
+    fail_unless(
836b22
+        debug_convert_old_level(SSSDBG_TRACE_LDB) == SSSDBG_TRACE_LDB,
836b22
+        "Invalid conversion of SSSDBG_TRACE_LDB"
836b22
+    );
836b22
     fail_unless(
836b22
         debug_convert_old_level(SSSDBG_MASK_ALL) == SSSDBG_MASK_ALL,
836b22
         "Invalid conversion of SSSDBG_MASK_ALL"
836b22
@@ -335,7 +340,8 @@ START_TEST(test_debug_is_set_single_no_timestamp)
836b22
         SSSDBG_TRACE_FUNC,
836b22
         SSSDBG_TRACE_LIBS,
836b22
         SSSDBG_TRACE_INTERNAL,
836b22
-        SSSDBG_TRACE_ALL
836b22
+        SSSDBG_TRACE_ALL,
836b22
+        SSSDBG_TRACE_LDB
836b22
     };
836b22
     char *error_msg;
836b22
 
836b22
@@ -345,7 +351,7 @@ START_TEST(test_debug_is_set_single_no_timestamp)
836b22
     debug_prg_name = "sssd";
836b22
     sss_set_logger(sss_logger_str[FILES_LOGGER]);
836b22
 
836b22
-    for (i = 0; i <= 9; i++) {
836b22
+    for (i = 0; i < N_ELEMENTS(levels); i++) {
836b22
         debug_level = levels[i];
836b22
 
836b22
         errno = 0;
836b22
@@ -378,7 +384,8 @@ START_TEST(test_debug_is_set_single_timestamp)
836b22
         SSSDBG_TRACE_FUNC,
836b22
         SSSDBG_TRACE_LIBS,
836b22
         SSSDBG_TRACE_INTERNAL,
836b22
-        SSSDBG_TRACE_ALL
836b22
+        SSSDBG_TRACE_ALL,
836b22
+        SSSDBG_TRACE_LDB
836b22
     };
836b22
     char *error_msg;
836b22
 
836b22
@@ -389,7 +396,7 @@ START_TEST(test_debug_is_set_single_timestamp)
836b22
     sss_set_logger(sss_logger_str[FILES_LOGGER]);
836b22
 
836b22
 
836b22
-    for (i = 0; i <= 9; i++) {
836b22
+    for (i = 0; i < N_ELEMENTS(levels); i++) {
836b22
         debug_level = levels[i];
836b22
 
836b22
         errno = 0;
836b22
@@ -427,7 +434,8 @@ START_TEST(test_debug_is_set_single_timestamp_microseconds)
836b22
         SSSDBG_TRACE_FUNC,
836b22
         SSSDBG_TRACE_LIBS,
836b22
         SSSDBG_TRACE_INTERNAL,
836b22
-        SSSDBG_TRACE_ALL
836b22
+        SSSDBG_TRACE_ALL,
836b22
+        SSSDBG_TRACE_LDB
836b22
     };
836b22
     char *error_msg;
836b22
 
836b22
@@ -438,7 +446,7 @@ START_TEST(test_debug_is_set_single_timestamp_microseconds)
836b22
     sss_set_logger(sss_logger_str[FILES_LOGGER]);
836b22
 
836b22
 
836b22
-    for (i = 0; i <= 9; i++) {
836b22
+    for (i = 0; i < N_ELEMENTS(levels); i++) {
836b22
         debug_level = levels[i];
836b22
 
836b22
         errno = 0;
836b22
@@ -477,7 +485,8 @@ START_TEST(test_debug_is_notset_no_timestamp)
836b22
         SSSDBG_TRACE_FUNC,
836b22
         SSSDBG_TRACE_LIBS,
836b22
         SSSDBG_TRACE_INTERNAL,
836b22
-        SSSDBG_TRACE_ALL
836b22
+        SSSDBG_TRACE_ALL,
836b22
+        SSSDBG_TRACE_LDB
836b22
     };
836b22
     char *error_msg;
836b22
 
836b22
@@ -488,7 +497,7 @@ START_TEST(test_debug_is_notset_no_timestamp)
836b22
     sss_set_logger(sss_logger_str[FILES_LOGGER]);
836b22
 
836b22
 
836b22
-    for (i = 0; i <= 9; i++) {
836b22
+    for (i = 0; i < N_ELEMENTS(levels); i++) {
836b22
         debug_level = all_set & ~levels[i];
836b22
 
836b22
         errno = 0;
836b22
@@ -524,7 +533,8 @@ START_TEST(test_debug_is_notset_timestamp)
836b22
         SSSDBG_TRACE_FUNC,
836b22
         SSSDBG_TRACE_LIBS,
836b22
         SSSDBG_TRACE_INTERNAL,
836b22
-        SSSDBG_TRACE_ALL
836b22
+        SSSDBG_TRACE_ALL,
836b22
+        SSSDBG_TRACE_LDB
836b22
     };
836b22
     char *error_msg;
836b22
 
836b22
@@ -535,7 +545,7 @@ START_TEST(test_debug_is_notset_timestamp)
836b22
     sss_set_logger(sss_logger_str[FILES_LOGGER]);
836b22
 
836b22
 
836b22
-    for (i = 0; i <= 9; i++) {
836b22
+    for (i = 0; i < N_ELEMENTS(levels); i++) {
836b22
         debug_level = all_set & ~levels[i];
836b22
 
836b22
         errno = 0;
836b22
@@ -571,7 +581,8 @@ START_TEST(test_debug_is_notset_timestamp_microseconds)
836b22
         SSSDBG_TRACE_FUNC,
836b22
         SSSDBG_TRACE_LIBS,
836b22
         SSSDBG_TRACE_INTERNAL,
836b22
-        SSSDBG_TRACE_ALL
836b22
+        SSSDBG_TRACE_ALL,
836b22
+        SSSDBG_TRACE_LDB
836b22
     };
836b22
     char *error_msg;
836b22
 
836b22
@@ -581,7 +592,7 @@ START_TEST(test_debug_is_notset_timestamp_microseconds)
836b22
     debug_prg_name = "sssd";
836b22
     sss_set_logger(sss_logger_str[FILES_LOGGER]);
836b22
 
836b22
-    for (i = 0; i <= 9; i++) {
836b22
+    for (i = 0; i < N_ELEMENTS(levels); i++) {
836b22
         debug_level = all_set & ~levels[i];
836b22
 
836b22
         errno = 0;
836b22
@@ -616,12 +627,13 @@ START_TEST(test_debug_is_set_true)
836b22
         SSSDBG_TRACE_FUNC,
836b22
         SSSDBG_TRACE_LIBS,
836b22
         SSSDBG_TRACE_INTERNAL,
836b22
-        SSSDBG_TRACE_ALL
836b22
+        SSSDBG_TRACE_ALL,
836b22
+        SSSDBG_TRACE_LDB
836b22
     };
836b22
 
836b22
     debug_level = SSSDBG_MASK_ALL;
836b22
 
836b22
-    for (i = 0; i <= 9; i++) {
836b22
+    for (i = 0; i < N_ELEMENTS(levels); i++) {
836b22
         result = DEBUG_IS_SET(levels[i]);
836b22
         char *msg = NULL;
836b22
         msg = talloc_asprintf(NULL, "Test of level %#.4x failed - result is 0x%.4x", levels[i], result);
836b22
@@ -646,10 +658,11 @@ START_TEST(test_debug_is_set_false)
836b22
         SSSDBG_TRACE_FUNC,
836b22
         SSSDBG_TRACE_LIBS,
836b22
         SSSDBG_TRACE_INTERNAL,
836b22
-        SSSDBG_TRACE_ALL
836b22
+        SSSDBG_TRACE_ALL,
836b22
+        SSSDBG_TRACE_LDB
836b22
     };
836b22
 
836b22
-    for (i = 0; i <= 9; i++) {
836b22
+    for (i = 0; i < N_ELEMENTS(levels); i++) {
836b22
         debug_level = all_set & ~levels[i];
836b22
 
836b22
         result = DEBUG_IS_SET(levels[i]);
836b22
diff --git a/src/util/debug.c b/src/util/debug.c
836b22
index 0c8e42ad0..e2a76a414 100644
836b22
--- a/src/util/debug.c
836b22
+++ b/src/util/debug.c
836b22
@@ -170,6 +170,9 @@ int debug_convert_old_level(int old_level)
836b22
     if (old_level >= 9)
836b22
         new_level |= SSSDBG_TRACE_ALL | SSSDBG_BE_FO;
836b22
 
836b22
+    if (old_level >= 10)
836b22
+        new_level |= SSSDBG_TRACE_LDB;
836b22
+
836b22
     return new_level;
836b22
 }
836b22
 
836b22
@@ -345,7 +348,7 @@ void ldb_debug_messages(void *context, enum ldb_debug_level level,
836b22
         loglevel = SSSDBG_TRACE_FUNC;
836b22
         break;
836b22
     case LDB_DEBUG_TRACE:
836b22
-        loglevel = SSSDBG_TRACE_ALL;
836b22
+        loglevel = SSSDBG_TRACE_LDB;
836b22
         break;
836b22
     }
836b22
 
836b22
diff --git a/src/util/debug.h b/src/util/debug.h
836b22
index 09f50cc9f..134005532 100644
836b22
--- a/src/util/debug.h
836b22
+++ b/src/util/debug.h
836b22
@@ -80,11 +80,16 @@ int get_fd_from_debug_file(void);
836b22
 #define SSSDBG_TRACE_INTERNAL 0x2000   /* level 8 */
836b22
 #define SSSDBG_TRACE_ALL      0x4000   /* level 9 */
836b22
 #define SSSDBG_BE_FO          0x8000   /* level 9 */
836b22
+#define SSSDBG_TRACE_LDB     0x10000   /* level 10 */
836b22
 #define SSSDBG_IMPORTANT_INFO SSSDBG_OP_FAILURE
836b22
 
836b22
 #define SSSDBG_INVALID        -1
836b22
 #define SSSDBG_UNRESOLVED     0
836b22
-#define SSSDBG_MASK_ALL       0xFFF0   /* enable all debug levels */
836b22
+
836b22
+/* enables all debug levels;
836b22
+   0x0800 isn't used for historical reasons: 0x1FFF0 - 0x0800 = 0x1F7F0
836b22
+*/
836b22
+#define SSSDBG_MASK_ALL       0x1F7F0
836b22
 #define SSSDBG_DEFAULT        SSSDBG_FATAL_FAILURE
836b22
 
836b22
 #define SSSDBG_TIMESTAMP_UNRESOLVED   -1
836b22
-- 
836b22
2.21.1
836b22