summaryrefslogtreecommitdiff
path: root/source3/include/debug.h
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2001-02-12 16:18:02 +0000
committerJeremy Allison <jra@samba.org>2001-02-12 16:18:02 +0000
commit94fc44a93c46cece9b9fa947bff62087dbcd89fa (patch)
tree292e61a7af5427e683d483a7afd802933ced9b72 /source3/include/debug.h
parentb4b387e31b241dcf4c8359c8515db689946654d5 (diff)
downloadsamba-94fc44a93c46cece9b9fa947bff62087dbcd89fa.tar.gz
samba-94fc44a93c46cece9b9fa947bff62087dbcd89fa.tar.bz2
samba-94fc44a93c46cece9b9fa947bff62087dbcd89fa.zip
Merge of JohnR's changes to appliance-head, JF's changes to 2.2,
updated the POSIX_ACL code to be in sync. Jeremy. (This used to be commit c0517d6f4e3079feca1309fd1ea7b21e83f0de02)
Diffstat (limited to 'source3/include/debug.h')
-rw-r--r--source3/include/debug.h132
1 files changed, 109 insertions, 23 deletions
diff --git a/source3/include/debug.h b/source3/include/debug.h
index 3130bc379d..d2c3b1d37e 100644
--- a/source3/include/debug.h
+++ b/source3/include/debug.h
@@ -66,38 +66,124 @@ BOOL dbgtext();
#define FUNCTION_MACRO ("")
#endif
-/* Debugging macros.
- * DEBUGLVL() - If level is <= the system-wide DEBUGLEVEL then generate a
- * header using the default macros for file, line, and
- * function name.
- * Returns True if the debug level was <= DEBUGLEVEL.
- * Example usage:
- * if( DEBUGLVL( 2 ) )
- * dbgtext( "Some text.\n" );
- * DEBUG() - Good old DEBUG(). Each call to DEBUG() will generate a new
- * header *unless* the previous debug output was unterminated
- * (i.e., no '\n'). See debug.c:dbghdr() for more info.
- * Example usage:
- * DEBUG( 2, ("Some text.\n") );
- * DEBUGADD() - If level <= DEBUGLEVEL, then the text is appended to the
- * current message (i.e., no header).
- * Usage:
- * DEBUGADD( 2, ("Some additional text.\n") );
+/*
+ * Redefine DEBUGLEVEL because so we don't have to change every source file
+ * that *unnecessarily* references it. Source files neeed not extern reference
+ * DEBUGLEVEL, as it's extern in includes.h (which all source files include).
+ * Eventually, all these references should be removed, and all references to
+ * DEBUGLEVEL should be references to DEBUGLEVEL_CLASS[DBGC_ALL]. This could
+ * still be through a macro still called DEBUGLEVEL. This cannot be done now
+ * because some references would expand incorrectly.
+ */
+#define DEBUGLEVEL *debug_level
+
+
+/*
+ * Define all new debug classes here. A class is represented by an entry in
+ * the DEBUGLEVEL_CLASS array. Index zero of this arrray is equivalent to the
+ * old DEBUGLEVEL. Any source file that does NOT add the following lines:
+ *
+ * #undef DBGC_CLASS
+ * #define DBGC_CLASS DBGC_<your class name here>
+ *
+ * at the start of the file (after #include "includes.h") will default to
+ * using index zero, so it will behaive just like it always has.
+ */
+#define DBGC_CLASS 0 /* override as shown above */
+#define DBGC_ALL 0 /* index equivalent to DEBUGLEVEL */
+
+#define DBGC_TDB 1
+#define DBGC_PRINTDRIVERS 2
+#define DBGC_LANMAN 3
+
+#define DBGC_LAST 4 /* MUST be last class value + 1 */
+
+
+extern int DEBUGLEVEL_CLASS[DBGC_LAST];
+
+
+/* Debugging macros
+ *
+ * DEBUGLVL()
+ * If the 'file specific' debug class level >= level OR the system-wide
+ * DEBUGLEVEL (synomym for DEBUGLEVEL_CLASS[ DBGC_ALL ]) >= level then
+ * generate a header using the default macros for file, line, and
+ * function name. Returns True if the debug level was <= DEBUGLEVEL.
+ *
+ * Example: if( DEBUGLVL( 2 ) ) dbgtext( "Some text.\n" );
+ *
+ * DEBUGLVLC()
+ * If the 'macro specified' debug class level >= level OR the system-wide
+ * DEBUGLEVEL (synomym for DEBUGLEVEL_CLASS[ DBGC_ALL ]) >= level then
+ * generate a header using the default macros for file, line, and
+ * function name. Returns True if the debug level was <= DEBUGLEVEL.
+ *
+ * Example: if( DEBUGLVL( DBGC_TDB, 2 ) ) dbgtext( "Some text.\n" );
+ *
+ * DEBUG()
+ * If the 'file specific' debug class level >= level OR the system-wide
+ * DEBUGLEVEL (synomym for DEBUGLEVEL_CLASS[ DBGC_ALL ]) >= level then
+ * generate a header using the default macros for file, line, and
+ * function name. Each call to DEBUG() generates a new header *unless* the
+ * previous debug output was unterminated (i.e. no '\n').
+ * See debug.c:dbghdr() for more info.
+ *
+ * Example: DEBUG( 2, ("Some text and a valu %d.\n", value) );
+ *
+ * DEBUGC()
+ * If the 'macro specified' debug class level >= level OR the system-wide
+ * DEBUGLEVEL (synomym for DEBUGLEVEL_CLASS[ DBGC_ALL ]) >= level then
+ * generate a header using the default macros for file, line, and
+ * function name. Each call to DEBUG() generates a new header *unless* the
+ * previous debug output was unterminated (i.e. no '\n').
+ * See debug.c:dbghdr() for more info.
+ *
+ * Example: DEBUG( DBGC_TDB, 2, ("Some text and a valu %d.\n", value) );
+ *
+ * DEBUGADD(), DEBUGADDC()
+ * Same as DEBUG() and DEBUGC() except the text is appended to the previous
+ * DEBUG(), DEBUGC(), DEBUGADD(), DEBUGADDC() with out another interviening
+ * header.
+ *
+ * Example: DEBUGADD( 2, ("Some text and a valu %d.\n", value) );
+ * DEBUGADDC( DBGC_TDB, 2, ("Some text and a valu %d.\n", value) );
+ *
+ * Note: If the debug class has not be redeined (see above) then the optimizer
+ * will remove the extra conditional test.
*/
+
#define DEBUGLVL( level ) \
- ( (DEBUGLEVEL >= (level)) \
+ ( ((DEBUGLEVEL_CLASS[ DBGC_CLASS ] >= (level))|| \
+ (DEBUGLEVEL_CLASS[ DBGC_ALL ] >= (level)) ) \
+ && dbghdr( level, FILE_MACRO, FUNCTION_MACRO, (__LINE__) ) )
+
+
+#define DEBUGLVLC( dbgc_class, level ) \
+ ( ((DEBUGLEVEL_CLASS[ dbgc_class ] >= (level))|| \
+ (DEBUGLEVEL_CLASS[ DBGC_ALL ] >= (level)) ) \
&& dbghdr( level, FILE_MACRO, FUNCTION_MACRO, (__LINE__) ) )
+
#define DEBUG( level, body ) \
- (void)( (DEBUGLEVEL >= (level)) \
+ (void)( ((DEBUGLEVEL_CLASS[ DBGC_CLASS ] >= (level))|| \
+ (DEBUGLEVEL_CLASS[ DBGC_ALL ] >= (level)) ) \
+ && (dbghdr( level, FILE_MACRO, FUNCTION_MACRO, (__LINE__) )) \
+ && (dbgtext body) )
+
+#define DEBUGC( dbgc_class, level, body ) \
+ (void)( ((DEBUGLEVEL_CLASS[ dbgc_class ] >= (level))|| \
+ (DEBUGLEVEL_CLASS[ DBGC_ALL ] >= (level)) ) \
&& (dbghdr( level, FILE_MACRO, FUNCTION_MACRO, (__LINE__) )) \
&& (dbgtext body) )
#define DEBUGADD( level, body ) \
- (void)( (DEBUGLEVEL >= (level)) && (dbgtext body) )
+ (void)( ((DEBUGLEVEL_CLASS[ DBGC_CLASS ] >= (level))|| \
+ (DEBUGLEVEL_CLASS[ DBGC_ALL ] >= (level)) ) \
+ && (dbgtext body) )
-/* End Debugging code section.
- * -------------------------------------------------------------------------- **
- */
+#define DEBUGADDC( dbgc_class, level, body ) \
+ (void)( ((DEBUGLEVEL_CLASS[ dbgc_class ] >= (level))|| \
+ (DEBUGLEVEL_CLASS[ DBGC_ALL ] >= (level)) ) \
+ && (dbgtext body) )
#endif