summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2019-04-26 13:40:58 +0200
committerKarolin Seeger <kseeger@samba.org>2019-08-08 07:30:11 +0000
commit1dcb5dc3844b65cee056f552a0565abf210942dd (patch)
tree88eeba7e5ad007c1e65f7daa568fd1a067b37a49
parent823d57094b992d4287487932c72d308f4d94d6a3 (diff)
downloadsamba-1dcb5dc3844b65cee056f552a0565abf210942dd.tar.gz
lib/util: set current_msg_{level,class} also during a DEBUGADD[C]() call
In some situations we use DEBUGADDC() in order to print out content without a related debug header line. This is important with the new per class logfile with: log level = 1 dsdb_json_audit:10@/var/log/samba/log.dsdb_json_audit BUG: https://bugzilla.samba.org/show_bug.cgi?id=13915 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org> (cherry picked from commit 0da12ff93d213ac742eeb865bfa5697ca8a2280a)
-rw-r--r--lib/util/debug.c17
-rw-r--r--lib/util/debug.h7
2 files changed, 17 insertions, 7 deletions
diff --git a/lib/util/debug.c b/lib/util/debug.c
index 7f3d13da53c..38df787c658 100644
--- a/lib/util/debug.c
+++ b/lib/util/debug.c
@@ -1475,6 +1475,17 @@ void dbgflush( void )
bufr_print();
}
+bool dbgsetclass(int level, int cls)
+{
+ /* Set current_msg_level. */
+ current_msg_level = level;
+
+ /* Set current message class */
+ current_msg_class = cls;
+
+ return true;
+}
+
/***************************************************************************
Print a Debug Header.
@@ -1519,11 +1530,7 @@ bool dbghdrclass(int level, int cls, const char *location, const char *func)
return( true );
}
- /* Set current_msg_level. */
- current_msg_level = level;
-
- /* Set current message class */
- current_msg_class = cls;
+ dbgsetclass(level, cls);
/* Don't print a header if we're logging to stdout. */
if ( state.logtype != DEBUG_FILE ) {
diff --git a/lib/util/debug.h b/lib/util/debug.h
index 5c56d4fd675..67dbf3357e3 100644
--- a/lib/util/debug.h
+++ b/lib/util/debug.h
@@ -45,6 +45,7 @@
bool dbgtext_va(const char *, va_list ap) PRINTF_ATTRIBUTE(1,0);
bool dbgtext( const char *, ... ) PRINTF_ATTRIBUTE(1,2);
bool dbghdrclass( int level, int cls, const char *location, const char *func);
+bool dbgsetclass(int level, int cls);
/*
* Define all new debug classes here. A class is represented by an entry in
@@ -205,12 +206,14 @@ void debuglevel_set_class(size_t idx, int level);
#define DEBUGADD( level, body ) \
(void)( ((level) <= MAX_DEBUG_LEVEL) && \
- unlikely(debuglevel_get_class(DBGC_CLASS) >= (level)) \
+ unlikely(debuglevel_get_class(DBGC_CLASS) >= (level)) \
+ && (dbgsetclass(level, DBGC_CLASS)) \
&& (dbgtext body) )
#define DEBUGADDC( dbgc_class, level, body ) \
(void)( ((level) <= MAX_DEBUG_LEVEL) && \
- unlikely((debuglevel_get_class(dbgc_class) >= (level))) \
+ unlikely((debuglevel_get_class(dbgc_class) >= (level))) \
+ && (dbgsetclass(level, dbgc_class)) \
&& (dbgtext body) )
/* Print a separator to the debug log. */