diff options
author | Kai Blin <kai@samba.org> | 2013-01-18 09:44:02 +0100 |
---|---|---|
committer | Kai Blin <kai@samba.org> | 2013-05-18 10:58:05 +0200 |
commit | 30cba0d201fc91cff30b6ea2bd11979930650169 (patch) | |
tree | 7fe5d47b9994b087006d42ee9f0dc759e0675e80 | |
parent | 1c9ef675d1a44fb9b0d599f96391abf1e21981c1 (diff) | |
download | samba-30cba0d201fc91cff30b6ea2bd11979930650169.tar.gz samba-30cba0d201fc91cff30b6ea2bd11979930650169.tar.bz2 samba-30cba0d201fc91cff30b6ea2bd11979930650169.zip |
debug: Add ability to dump_data per debug class
Signed-off-by: Kai Blin <kai@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
-rw-r--r-- | lib/util/debug.h | 7 | ||||
-rw-r--r-- | lib/util/samba_util.h | 8 | ||||
-rw-r--r-- | lib/util/util.c | 30 |
3 files changed, 45 insertions, 0 deletions
diff --git a/lib/util/debug.h b/lib/util/debug.h index feea0a8d94..30df78732a 100644 --- a/lib/util/debug.h +++ b/lib/util/debug.h @@ -161,10 +161,17 @@ extern int *DEBUGLEVEL_CLASS; ( ((level) <= MAX_DEBUG_LEVEL) && \ unlikely(DEBUGLEVEL_CLASS[ DBGC_CLASS ] >= (level))) +#define CHECK_DEBUGLVLC( dbgc_class, level ) \ + ( ((level) <= MAX_DEBUG_LEVEL) && \ + unlikely(DEBUGLEVEL_CLASS[ dbgc_class ] >= (level))) + #define DEBUGLVL( level ) \ ( CHECK_DEBUGLVL(level) \ && dbghdrclass( level, DBGC_CLASS, __location__, __FUNCTION__ ) ) +#define DEBUGLVLC( dbgc_class, level ) \ + ( CHECK_DEBUGLVLC( dbgc_class, level ) \ + && dbghdrclass( level, dbgc_class, __location__, __FUNCTION__ ) ) #define DEBUG( level, body ) \ (void)( ((level) <= MAX_DEBUG_LEVEL) && \ diff --git a/lib/util/samba_util.h b/lib/util/samba_util.h index 6a4373e424..89aa9aa7d8 100644 --- a/lib/util/samba_util.h +++ b/lib/util/samba_util.h @@ -693,6 +693,14 @@ _PUBLIC_ void dump_data(int level, const uint8_t *buf,int len); /** * Write dump of binary data to the log file. * + * The data is only written if the log level is at least level for + * debug class dbgc_class. + */ +_PUBLIC_ void dump_data_dbgc(int dbgc_class, int level, const uint8_t *buf, int len); + +/** + * Write dump of binary data to the log file. + * * The data is only written if the log level is at least level. * 16 zero bytes in a row are omitted */ diff --git a/lib/util/util.c b/lib/util/util.c index 7962c1e2ea..7c669fbd5e 100644 --- a/lib/util/util.c +++ b/lib/util/util.c @@ -384,6 +384,19 @@ _PUBLIC_ bool fcntl_lock(int fd, int op, off_t offset, off_t count, int type) return true; } +struct debug_channel_level { + int channel; + int level; +}; + +static void debugadd_channel_cb(const char *buf, void *private_data) +{ + struct debug_channel_level *dcl = + (struct debug_channel_level *)private_data; + + DEBUGADDC(dcl->channel, dcl->level,("%s", buf)); +} + static void debugadd_cb(const char *buf, void *private_data) { int *plevel = (int *)private_data; @@ -505,6 +518,23 @@ _PUBLIC_ void dump_data(int level, const uint8_t *buf, int len) /** * Write dump of binary data to the log file. * + * The data is only written if the log level is at least level for + * debug class dbgc_class. + */ +_PUBLIC_ void dump_data_dbgc(int dbgc_class, int level, const uint8_t *buf, int len) +{ + struct debug_channel_level dcl = { dbgc_class, level }; + + if (!DEBUGLVLC(dbgc_class, level)) { + DEBUG(0, ("dbgc_class is %d\n", dbgc_class)); + return; + } + dump_data_cb(buf, len, false, debugadd_channel_cb, &dcl); +} + +/** + * Write dump of binary data to the log file. + * * The data is only written if the log level is at least level. * 16 zero bytes in a row are omitted */ |