]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libsmartcols: clean up debug, add help debug mask
authorKarel Zak <kzak@redhat.com>
Mon, 3 Nov 2014 12:13:22 +0000 (13:13 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 3 Nov 2014 12:13:22 +0000 (13:13 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
libsmartcols/src/init.c
libsmartcols/src/smartcolsP.h

index 9fec0356d54b19c9dd890ad23fe116e9bd9f8283..806b0e1a2ff1bb0e6f07a4bc79585d1c2e9389b7 100644 (file)
 #include "smartcolsP.h"
 
 UL_DEBUG_DEFINE_MASK(libsmartcols);
-
-static const struct dbg_mask libsmartcols_masknames [] = {
-       { "all", SCOLS_DEBUG_ALL },
-       { "cell", SCOLS_DEBUG_CELL },
-       { "line", SCOLS_DEBUG_LINE },
-       { "tab", SCOLS_DEBUG_TAB },
-       { "col", SCOLS_DEBUG_COL },
-       { "buff", SCOLS_DEBUG_BUFF },
-       { NULL, 0 }
+UL_DEBUG_DEFINE_MASKNAMES(libsmartcols) =
+{
+       { "all", SCOLS_DEBUG_ALL,       "info about all subsystems" },
+       { "buff", SCOLS_DEBUG_BUFF,     "output buffer utils" },
+       { "cell", SCOLS_DEBUG_CELL,     "table cell utils" },
+       { "col", SCOLS_DEBUG_COL,       "cols utils" },
+       { "help", SCOLS_DEBUG_HELP,     "this help" },
+       { "line", SCOLS_DEBUG_LINE,     "table line utils" },
+       { "tab", SCOLS_DEBUG_TAB,       "table utils" },
+       { NULL, 0, NULL }
 };
+
 /**
  * scols_init_debug:
  * @mask: debug mask (0xffff to enable full debugging)
@@ -40,13 +42,20 @@ static const struct dbg_mask libsmartcols_masknames [] = {
  */
 void scols_init_debug(int mask)
 {
+       if (libsmartcols_debug_mask)
+               return;
+
        __UL_INIT_DEBUG(libsmartcols, SCOLS_DEBUG_, mask, LIBSMARTCOLS_DEBUG);
 
-       if (libsmartcols_debug_mask != SCOLS_DEBUG_INIT) {
+       if (libsmartcols_debug_mask != SCOLS_DEBUG_INIT
+           && libsmartcols_debug_mask != (SCOLS_DEBUG_HELP|SCOLS_DEBUG_INIT)) {
                const char *ver = NULL;
 
                scols_get_library_version(&ver);
 
+               DBG(INIT, ul_debug("library debug mask: 0x%04x", libsmartcols_debug_mask));
                DBG(INIT, ul_debug("library version: %s", ver));
        }
+       ON_DBG(HELP, ul_debug_print_masks("LIBSMARTCOLS_DEBUG",
+                               UL_DEBUG_MASKNAMES(libsmartcols)));
 }
index 28246c14f7ba4f110b5d0f00a349c68c9eb9a6d3..511b182a249254d33d7c727a9f3339dc4eab4153 100644 (file)
@@ -30,6 +30,7 @@
 /*
  * Debug
  */
+#define SCOLS_DEBUG_HELP       (1 << 0)
 #define SCOLS_DEBUG_INIT       (1 << 1)
 #define SCOLS_DEBUG_CELL       (1 << 2)
 #define SCOLS_DEBUG_LINE       (1 << 3)