From cdde6d93605d15a59e816a35e8e02ca193bf1403 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 21 Mar 2018 12:40:50 -0700 Subject: lib: debug: Add DBGC_XXX versions of the macros to allow class-specific messages. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://bugzilla.samba.org/show_bug.cgi?id=13347 Signed-off-by: Jeremy Allison Reviewed-by: Ralph Böhme --- lib/util/debug.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'lib/util/debug.h') diff --git a/lib/util/debug.h b/lib/util/debug.h index 47280da1a78..1b17fad9694 100644 --- a/lib/util/debug.h +++ b/lib/util/debug.h @@ -217,6 +217,14 @@ extern int *DEBUGLEVEL_CLASS; && (dbgtext("%s: ", __func__)) \ && (dbgtext body) ) +/* Prefix messages with the function name - class specific */ +#define DBGC_PREFIX(dbgc_class, level, body ) \ + (void)( ((level) <= MAX_DEBUG_LEVEL) && \ + unlikely(DEBUGLEVEL_CLASS[ dbgc_class ] >= (level)) \ + && (dbghdrclass(level, dbgc_class, __location__, __func__ )) \ + && (dbgtext("%s: ", __func__)) \ + && (dbgtext body) ) + /* * Debug levels matching RFC 3164 */ @@ -232,12 +240,34 @@ extern int *DEBUGLEVEL_CLASS; #define DBG_INFO(...) DBG_PREFIX(DBGLVL_INFO, (__VA_ARGS__)) #define DBG_DEBUG(...) DBG_PREFIX(DBGLVL_DEBUG, (__VA_ARGS__)) +#define DBGC_ERR(dbgc_class, ...) DBGC_PREFIX(dbgc_class, \ + DBGLVL_ERR, (__VA_ARGS__)) +#define DBGC_WARNING(dbgc_class, ...) DBGC_PREFIX(dbgc_class, \ + DBGLVL_WARNING, (__VA_ARGS__)) +#define DBGC_NOTICE(dbgc_class, ...) DBGC_PREFIX(dbgc_class, \ + DBGLVL_NOTICE, (__VA_ARGS__)) +#define DBGC_INFO(dbgc_class, ...) DBGC_PREFIX(dbgc_class, \ + DBGLVL_INFO, (__VA_ARGS__)) +#define DBGC_DEBUG(dbgc_class, ...) DBGC_PREFIX(dbgc_class, \ + DBGLVL_DEBUG, (__VA_ARGS__)) + #define D_ERR(...) DEBUG(DBGLVL_ERR, (__VA_ARGS__)) #define D_WARNING(...) DEBUG(DBGLVL_WARNING, (__VA_ARGS__)) #define D_NOTICE(...) DEBUG(DBGLVL_NOTICE, (__VA_ARGS__)) #define D_INFO(...) DEBUG(DBGLVL_INFO, (__VA_ARGS__)) #define D_DEBUG(...) DEBUG(DBGLVL_DEBUG, (__VA_ARGS__)) +#define DC_ERR(...) DEBUGC(dbgc_class, \ + DBGLVL_ERR, (__VA_ARGS__)) +#define DC_WARNING(...) DEBUGC(dbgc_class, \ + DBGLVL_WARNING, (__VA_ARGS__)) +#define DC_NOTICE(...) DEBUGC(dbgc_class, \ + DBGLVL_NOTICE, (__VA_ARGS__)) +#define DC_INFO(...) DEBUGC(dbgc_class, \ + DBGLVL_INFO, (__VA_ARGS__)) +#define DC_DEBUG(...) DEBUGC(dbgc_class, \ + DBGLVL_DEBUG, (__VA_ARGS__)) + /* The following definitions come from lib/debug.c */ /** Possible destinations for the debug log (in order of precedence - -- cgit v1.2.1