Add the option to print the debug class (DBGC_CLASS) in the debug header.
authorobnox <obnox@0c0555d6-39d7-0310-84fc-f1cc0bd64818>
Sun, 30 Sep 2007 08:07:06 +0000 (08:07 +0000)
committerobnox <obnox@0c0555d6-39d7-0310-84fc-f1cc0bd64818>
Sun, 30 Sep 2007 08:07:06 +0000 (08:07 +0000)
Control this by a new boolean smb.conf option "debug class" which is
by default set to "no" to keep the default debug header unchanged.

Michael

Note: You need to make clean for this patch.

git-svn-id: svn+ssh://svn.samba.org/data/svn/samba/branches/SAMBA_3_2@25434 0c0555d6-39d7-0310-84fc-f1cc0bd64818

source/include/debug.h
source/lib/debug.c
source/param/loadparm.c

index dca3bc008c1d009c3bbba4f3daaeb2923c2c9426..eb7dc76c1c4f24b2aa2c3a3c0c9c19fc004bf51b 100644 (file)
@@ -40,7 +40,7 @@
 int  Debug1( const char *, ... ) PRINTF_ATTRIBUTE(1,2);
 /* PRINTFLIKE1 */
 BOOL dbgtext( const char *, ... ) PRINTF_ATTRIBUTE(1,2);
 int  Debug1( const char *, ... ) PRINTF_ATTRIBUTE(1,2);
 /* PRINTFLIKE1 */
 BOOL dbgtext( const char *, ... ) PRINTF_ATTRIBUTE(1,2);
-BOOL dbghdr( int level, const char *file, const char *func, int line );
+BOOL dbghdr( int level, int cls, const char *file, const char *func, int line );
 
 #if defined(sgi) && (_COMPILER_VERSION >= 730)
 #pragma mips_frequency_hint NEVER Debug1
 
 #if defined(sgi) && (_COMPILER_VERSION >= 730)
 #pragma mips_frequency_hint NEVER Debug1
@@ -167,7 +167,7 @@ extern BOOL *DEBUGLEVEL_CLASS_ISSET;
      ((DEBUGLEVEL_CLASS[ DBGC_CLASS ] >= (level))||  \
      (!DEBUGLEVEL_CLASS_ISSET[ DBGC_CLASS ] && \
       DEBUGLEVEL_CLASS[ DBGC_ALL   ] >= (level))  ) \
      ((DEBUGLEVEL_CLASS[ DBGC_CLASS ] >= (level))||  \
      (!DEBUGLEVEL_CLASS_ISSET[ DBGC_CLASS ] && \
       DEBUGLEVEL_CLASS[ DBGC_ALL   ] >= (level))  ) \
-   && dbghdr( level, __FILE__, FUNCTION_MACRO, (__LINE__) ) )
+   && dbghdr( level, DBGC_CLASS, __FILE__, FUNCTION_MACRO, (__LINE__) ) )
 
 
 #define DEBUGLVLC( dbgc_class, level ) \
 
 
 #define DEBUGLVLC( dbgc_class, level ) \
@@ -175,7 +175,7 @@ extern BOOL *DEBUGLEVEL_CLASS_ISSET;
      ((DEBUGLEVEL_CLASS[ dbgc_class ] >= (level))||  \
      (!DEBUGLEVEL_CLASS_ISSET[ dbgc_class ] && \
       DEBUGLEVEL_CLASS[ DBGC_ALL   ] >= (level))  ) \
      ((DEBUGLEVEL_CLASS[ dbgc_class ] >= (level))||  \
      (!DEBUGLEVEL_CLASS_ISSET[ dbgc_class ] && \
       DEBUGLEVEL_CLASS[ DBGC_ALL   ] >= (level))  ) \
-   && dbghdr( level, __FILE__, FUNCTION_MACRO, (__LINE__) ) )
+   && dbghdr( level, DBGC_CLASS, __FILE__, FUNCTION_MACRO, (__LINE__) ) )
 
 
 #define DEBUG( level, body ) \
 
 
 #define DEBUG( level, body ) \
@@ -183,7 +183,7 @@ extern BOOL *DEBUGLEVEL_CLASS_ISSET;
            ((DEBUGLEVEL_CLASS[ DBGC_CLASS ] >= (level))||  \
            (!DEBUGLEVEL_CLASS_ISSET[ DBGC_CLASS ] && \
             DEBUGLEVEL_CLASS[ DBGC_ALL   ] >= (level))  ) \
            ((DEBUGLEVEL_CLASS[ DBGC_CLASS ] >= (level))||  \
            (!DEBUGLEVEL_CLASS_ISSET[ DBGC_CLASS ] && \
             DEBUGLEVEL_CLASS[ DBGC_ALL   ] >= (level))  ) \
-       && (dbghdr( level, __FILE__, FUNCTION_MACRO, (__LINE__) )) \
+       && (dbghdr( level, DBGC_CLASS, __FILE__, FUNCTION_MACRO, (__LINE__) )) \
        && (dbgtext body) )
 
 #define DEBUGC( dbgc_class, level, body ) \
        && (dbgtext body) )
 
 #define DEBUGC( dbgc_class, level, body ) \
@@ -191,7 +191,7 @@ extern BOOL *DEBUGLEVEL_CLASS_ISSET;
            ((DEBUGLEVEL_CLASS[ dbgc_class ] >= (level))||  \
            (!DEBUGLEVEL_CLASS_ISSET[ dbgc_class ] && \
            DEBUGLEVEL_CLASS[ DBGC_ALL   ] >= (level))  ) \
            ((DEBUGLEVEL_CLASS[ dbgc_class ] >= (level))||  \
            (!DEBUGLEVEL_CLASS_ISSET[ dbgc_class ] && \
            DEBUGLEVEL_CLASS[ DBGC_ALL   ] >= (level))  ) \
-       && (dbghdr( level, __FILE__, FUNCTION_MACRO, (__LINE__) )) \
+       && (dbghdr( level, DBGC_CLASS, __FILE__, FUNCTION_MACRO, (__LINE__) )) \
        && (dbgtext body) )
 
 #define DEBUGADD( level, body ) \
        && (dbgtext body) )
 
 #define DEBUGADD( level, body ) \
index fc7b1d67f6230c666b494796d14f787599754806..69da08be771e65af49da36aa507f47fa20bcab73 100644 (file)
@@ -913,6 +913,7 @@ void dbgflush( void )
 
  Input:  level - Debug level of the message (not the system-wide debug
                   level. )
 
  Input:  level - Debug level of the message (not the system-wide debug
                   level. )
+         cls   - Debuglevel class of the calling module.
           file  - Pointer to a string containing the name of the file
                   from which this function was called, or an empty string
                   if the __FILE__ macro is not implemented.
           file  - Pointer to a string containing the name of the file
                   from which this function was called, or an empty string
                   if the __FILE__ macro is not implemented.
@@ -930,7 +931,7 @@ void dbgflush( void )
 
 ****************************************************************************/
 
 
 ****************************************************************************/
 
-BOOL dbghdr( int level, const char *file, const char *func, int line )
+BOOL dbghdr(int level, int cls, const char *file, const char *func, int line)
 {
        /* Ensure we don't lose any real errno value. */
        int old_errno = errno;
 {
        /* Ensure we don't lose any real errno value. */
        int old_errno = errno;
@@ -976,6 +977,14 @@ BOOL dbghdr( int level, const char *file, const char *func, int line )
                                (unsigned int)geteuid(), (unsigned int)getegid(),
                                (unsigned int)getuid(), (unsigned int)getgid()); 
                }
                                (unsigned int)geteuid(), (unsigned int)getegid(),
                                (unsigned int)getuid(), (unsigned int)getgid()); 
                }
+
+               if (lp_debug_class() && (cls != DBGC_ALL)) {
+                       size_t hs_len = strlen(header_str);
+                       slprintf(header_str + hs_len,
+                                sizeof(header_str) -1 - hs_len,
+                                ", class=%s",
+                                default_classname_table[cls]);
+               }
   
                /* Print it all out at once to prevent split syslog output. */
                if( lp_debug_prefix_timestamp() ) {
   
                /* Print it all out at once to prevent split syslog output. */
                if( lp_debug_prefix_timestamp() ) {
index b49d7b54a96c555a6253f77c89d1cde74005bbf0..d7e15226e9967a21fb84306b4b5b48e70d9fdacc 100644 (file)
@@ -306,6 +306,7 @@ typedef struct {
        BOOL bDebugHiresTimestamp;
        BOOL bDebugPid;
        BOOL bDebugUid;
        BOOL bDebugHiresTimestamp;
        BOOL bDebugPid;
        BOOL bDebugUid;
+       BOOL bDebugClass;
        BOOL bEnableCoreFiles;
        BOOL bHostMSDfs;
        BOOL bUseMmap;
        BOOL bEnableCoreFiles;
        BOOL bHostMSDfs;
        BOOL bUseMmap;
@@ -981,6 +982,7 @@ static struct parm_struct parm_table[] = {
        {"debug hires timestamp", P_BOOL, P_GLOBAL, &Globals.bDebugHiresTimestamp, NULL, NULL, FLAG_ADVANCED}, 
        {"debug pid", P_BOOL, P_GLOBAL, &Globals.bDebugPid, NULL, NULL, FLAG_ADVANCED}, 
        {"debug uid", P_BOOL, P_GLOBAL, &Globals.bDebugUid, NULL, NULL, FLAG_ADVANCED}, 
        {"debug hires timestamp", P_BOOL, P_GLOBAL, &Globals.bDebugHiresTimestamp, NULL, NULL, FLAG_ADVANCED}, 
        {"debug pid", P_BOOL, P_GLOBAL, &Globals.bDebugPid, NULL, NULL, FLAG_ADVANCED}, 
        {"debug uid", P_BOOL, P_GLOBAL, &Globals.bDebugUid, NULL, NULL, FLAG_ADVANCED}, 
+       {"debug class", P_BOOL, P_GLOBAL, &Globals.bDebugClass, NULL, NULL, FLAG_ADVANCED},
        {"enable core files", P_BOOL, P_GLOBAL, &Globals.bEnableCoreFiles, NULL, NULL, FLAG_ADVANCED},
 
        {N_("Protocol Options"), P_SEP, P_SEPARATOR}, 
        {"enable core files", P_BOOL, P_GLOBAL, &Globals.bEnableCoreFiles, NULL, NULL, FLAG_ADVANCED},
 
        {N_("Protocol Options"), P_SEP, P_SEPARATOR}, 
@@ -1547,6 +1549,7 @@ static void init_globals(BOOL first_time_only)
        Globals.bDebugHiresTimestamp = False;
        Globals.bDebugPid = False;
        Globals.bDebugUid = False;
        Globals.bDebugHiresTimestamp = False;
        Globals.bDebugPid = False;
        Globals.bDebugUid = False;
+       Globals.bDebugClass = False;
        Globals.bEnableCoreFiles = True;
        Globals.max_ttl = 60 * 60 * 24 * 3;     /* 3 days default. */
        Globals.max_wins_ttl = 60 * 60 * 24 * 6;        /* 6 days default. */
        Globals.bEnableCoreFiles = True;
        Globals.max_ttl = 60 * 60 * 24 * 3;     /* 3 days default. */
        Globals.max_wins_ttl = 60 * 60 * 24 * 6;        /* 6 days default. */
@@ -1958,6 +1961,7 @@ FN_GLOBAL_BOOL(lp_debug_prefix_timestamp, &Globals.bDebugPrefixTimestamp)
 FN_GLOBAL_BOOL(lp_debug_hires_timestamp, &Globals.bDebugHiresTimestamp)
 FN_GLOBAL_BOOL(lp_debug_pid, &Globals.bDebugPid)
 FN_GLOBAL_BOOL(lp_debug_uid, &Globals.bDebugUid)
 FN_GLOBAL_BOOL(lp_debug_hires_timestamp, &Globals.bDebugHiresTimestamp)
 FN_GLOBAL_BOOL(lp_debug_pid, &Globals.bDebugPid)
 FN_GLOBAL_BOOL(lp_debug_uid, &Globals.bDebugUid)
+FN_GLOBAL_BOOL(lp_debug_class, &Globals.bDebugClass)
 FN_GLOBAL_BOOL(lp_enable_core_files, &Globals.bEnableCoreFiles)
 FN_GLOBAL_BOOL(lp_browse_list, &Globals.bBrowseList)
 FN_GLOBAL_BOOL(lp_nis_home_map, &Globals.bNISHomeMap)
 FN_GLOBAL_BOOL(lp_enable_core_files, &Globals.bEnableCoreFiles)
 FN_GLOBAL_BOOL(lp_browse_list, &Globals.bBrowseList)
 FN_GLOBAL_BOOL(lp_nis_home_map, &Globals.bNISHomeMap)