]> git.sur5r.net Git - openldap/commitdiff
allow comma-separated descriptive log levels, so that tests can be run, e.g., with...
authorPierangelo Masarati <ando@openldap.org>
Mon, 28 Nov 2005 10:55:07 +0000 (10:55 +0000)
committerPierangelo Masarati <ando@openldap.org>
Mon, 28 Nov 2005 10:55:07 +0000 (10:55 +0000)
servers/slapd/aclparse.c
servers/slapd/init.c
servers/slapd/main.c
servers/slapd/slapcommon.c

index 5a666a4650eda5feed604bf3e49e88121cade0a3..c9ae1809fe136d431487383bd6cff6ae994cb110 100644 (file)
@@ -1939,7 +1939,7 @@ parse_acl(
 
        } else {
 #ifdef LDAP_DEBUG
-               if ( ldap_debug & LDAP_DEBUG_ACL ) {
+               if ( slap_debug & LDAP_DEBUG_ACL ) {
                        print_acl( be, a );
                }
 #endif
index 6a68e498eec835b3128163c3f5bb387582ebcedc..be2c9b46489b04d28ae9ebc4d44cecbdebdd5a1c 100644 (file)
@@ -94,7 +94,7 @@ slap_init( int mode, const char *name )
 
        if ( slapMode != SLAP_UNDEFINED_MODE ) {
                /* Make sure we write something to stderr */
-               ldap_debug |= 1;
+               slap_debug |= LDAP_DEBUG_NONE;
                Debug( LDAP_DEBUG_ANY,
                 "%s init: init called twice (old=%d, new=%d)\n",
                 name, slapMode, mode );
@@ -106,7 +106,7 @@ slap_init( int mode, const char *name )
 
 #ifdef SLAPD_MODULES
        if ( module_init() != 0 ) {
-               ldap_debug |= 1;
+               slap_debug |= LDAP_DEBUG_NONE;
                Debug( LDAP_DEBUG_ANY,
                    "%s: module_init failed\n",
                        name, 0, 0 );
@@ -115,7 +115,7 @@ slap_init( int mode, const char *name )
 #endif
 
        if ( slap_schema_init( ) != 0 ) {
-               ldap_debug |= 1;
+               slap_debug |= LDAP_DEBUG_NONE;
                Debug( LDAP_DEBUG_ANY,
                    "%s: slap_schema_init failed\n",
                    name, 0, 0 );
@@ -176,7 +176,7 @@ slap_init( int mode, const char *name )
                break;
 
        default:
-               ldap_debug |= 1;
+               slap_debug |= LDAP_DEBUG_NONE;
                Debug( LDAP_DEBUG_ANY,
                        "%s init: undefined mode (%d).\n", name, mode, 0 );
 
@@ -185,7 +185,7 @@ slap_init( int mode, const char *name )
        }
 
        if ( slap_controls_init( ) != 0 ) {
-               ldap_debug |= 1;
+               slap_debug |= LDAP_DEBUG_NONE;
                Debug( LDAP_DEBUG_ANY,
                    "%s: slap_controls_init failed\n",
                    name, 0, 0 );
@@ -203,7 +203,7 @@ slap_init( int mode, const char *name )
 #endif
 
        if ( frontend_init() ) {
-               ldap_debug |= 1;
+               slap_debug |= LDAP_DEBUG_NONE;
                Debug( LDAP_DEBUG_ANY,
                    "%s: frontend_init failed\n",
                    name, 0, 0 );
@@ -211,7 +211,7 @@ slap_init( int mode, const char *name )
        }
 
        if ( overlay_init() ) {
-               ldap_debug |= 1;
+               slap_debug |= LDAP_DEBUG_NONE;
                Debug( LDAP_DEBUG_ANY,
                    "%s: overlay_init failed\n",
                    name, 0, 0 );
@@ -219,7 +219,7 @@ slap_init( int mode, const char *name )
        }
 
        if ( glue_sub_init() ) {
-               ldap_debug |= 1;
+               slap_debug |= LDAP_DEBUG_NONE;
                Debug( LDAP_DEBUG_ANY,
                    "%s: glue/subordinate init failed\n",
                    name, 0, 0 );
@@ -228,7 +228,7 @@ slap_init( int mode, const char *name )
        }
 
        if ( acl_init() ) {
-               ldap_debug |= 1;
+               slap_debug |= LDAP_DEBUG_NONE;
                Debug( LDAP_DEBUG_ANY,
                    "%s: acl_init failed\n",
                    name, 0, 0 );
index 3f5e91adf5d984fe880c551669877233e9b2d7eb..9b9f45f1f990ec9519c39f68b14918069c60dd91 100644 (file)
@@ -394,16 +394,29 @@ int main( int argc, char **argv )
 #ifdef LDAP_DEBUG
                        if ( optarg != NULL && optarg[ 0 ] != '-' && !isdigit( optarg[ 0 ] ) )
                        {
-                               int     level;
+                               int     level, i, goterr = 0;
+                               char    **levels;
 
-                               if ( str2loglevel( optarg, &level ) ) {
-                                       fprintf( stderr,
-                                               "unrecognized log level "
-                                               "\"%s\"\n", optarg );
+                               levels = ldap_str2charray( optarg, "," );
+
+                               for ( i = 0; levels[ i ] != NULL; i++ ) {
+                                       if ( str2loglevel( levels[ i ], &level ) ) {
+                                               fprintf( stderr,
+                                                       "unrecognized log level "
+                                                       "\"%s\"\n", levels[ i ] );
+                                               goterr = 1;
+
+                                       } else {
+                                               slap_debug |= level;
+                                       }
+                               }
+
+                               ldap_charray_free( levels );
+
+                               if ( goterr ) {
                                        goto destroy;
                                }
 
-                               slap_debug |= level;
                        } else {
                                int     level;
 
index 389998655a1a8fcf4627dab516789da61d4bab64..dc8ff261b3adc162bae7068e400c1e643ac43149 100644 (file)
@@ -195,7 +195,7 @@ slap_tool_init(
 #ifdef LDAP_DEBUG
        /* tools default to "none", so that at least LDAP_DEBUG_ANY 
         * messages show up; use -d 0 to reset */
-       ldap_debug = LDAP_DEBUG_NONE;
+       slap_debug = LDAP_DEBUG_NONE;
 #endif
 
 #ifdef CSRIMALLOC
@@ -263,38 +263,60 @@ slap_tool_init(
                        break;
 
                case 'd':       /* turn on debugging */
-                       {
 #ifdef LDAP_DEBUG
-                       int     level;
-
                        if ( optarg != NULL && optarg[ 0 ] != '-' && !isdigit( optarg[ 0 ] ) )
                        {
-                               if ( str2loglevel( optarg, &level ) ) {
+                               int     level, i, goterr = 0;
+                               char    **levels;
+
+                               levels = ldap_str2charray( optarg, "," );
+
+                               for ( i = 0; levels[ i ] != NULL; i++ ) {
+                                       if ( str2loglevel( levels[ i ], &level ) ) {
+                                               fprintf( stderr,
+                                                       "unrecognized log level "
+                                                       "\"%s\"\n", levels[ i ] );
+                                               goterr = 1;
+
+                                       } else {
+                                               if ( level ) {
+                                                       slap_debug |= level;
+                                               } else {
+                                                       /* allow to reset log level */
+                                                       slap_debug = 0;
+                                               }
+                                       }
+                               }
+
+                               ldap_charray_free( levels );
+
+                               if ( goterr ) {
+                                       usage( tool, progname );
+                               }
+
+                       } else {
+                               int     level;
+
+                               if ( lutil_atoix( &level, optarg, 0 ) != 0 ) {
                                        fprintf( stderr,
                                                "unrecognized log level "
                                                "\"%s\"\n", optarg );
-                                       exit( EXIT_FAILURE );
+                                       usage( tool, progname );
                                }
 
-                       } else if ( lutil_atoix( &level, optarg, 0 ) != 0 ) {
-                               fprintf( stderr,
-                                       "unrecognized log level "
-                                       "\"%s\"\n", optarg );
-                               exit( EXIT_FAILURE );
-                       }
-
-                       if ( level ) {
-                               ldap_debug |= level;
-                       } else {
-                               /* allow to reset log level */
-                               ldap_debug = 0;
+                               if ( level ) {
+                                       slap_debug |= level;
+                               } else {
+                                       /* allow to reset log level */
+                                       slap_debug = 0;
+                               }
                        }
 #else
                        if ( lutil_atoi( &level, optarg ) != 0 || level != 0 )
                                fputs( "must compile with LDAP_DEBUG for debugging\n",
                                       stderr );
 #endif
-                       break;
+                       break;
 
                case 'D':
                        ber_str2bv( optarg, 0, 1, &authcDN );