From: Pierangelo Masarati Date: Mon, 28 Nov 2005 10:55:07 +0000 (+0000) Subject: allow comma-separated descriptive log levels, so that tests can be run, e.g., with... X-Git-Tag: OPENLDAP_REL_ENG_2_4_BP~661 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=6459cbb7cedb281ae451448c99b3a66adaff6f46;p=openldap allow comma-separated descriptive log levels, so that tests can be run, e.g., with "SLAPD_DEBUG=stats,stats2"; s/ldap_debug/slap_debug/ --- diff --git a/servers/slapd/aclparse.c b/servers/slapd/aclparse.c index 5a666a4650..c9ae1809fe 100644 --- a/servers/slapd/aclparse.c +++ b/servers/slapd/aclparse.c @@ -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 diff --git a/servers/slapd/init.c b/servers/slapd/init.c index 6a68e498ee..be2c9b4648 100644 --- a/servers/slapd/init.c +++ b/servers/slapd/init.c @@ -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 ); diff --git a/servers/slapd/main.c b/servers/slapd/main.c index 3f5e91adf5..9b9f45f1f9 100644 --- a/servers/slapd/main.c +++ b/servers/slapd/main.c @@ -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; diff --git a/servers/slapd/slapcommon.c b/servers/slapd/slapcommon.c index 389998655a..dc8ff261b3 100644 --- a/servers/slapd/slapcommon.c +++ b/servers/slapd/slapcommon.c @@ -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 );