From 6315ac9db697f5e59d07f2bf9d4b96bbbbca4ca2 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Wed, 9 Nov 2005 11:53:34 +0000 Subject: [PATCH] tools log level defaults to "none", so that messages logged with LDAP_DEBUG_ANY show up by default; use "-d 0" to reset (addresses ITS#4044) --- servers/slapd/slapcommon.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/servers/slapd/slapcommon.c b/servers/slapd/slapcommon.c index f0fe956ad7..906d7a6046 100644 --- a/servers/slapd/slapcommon.c +++ b/servers/slapd/slapcommon.c @@ -180,6 +180,12 @@ slap_tool_init( int truncatemode = 0; int use_glue = 1; +#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; +#endif + #ifdef CSRIMALLOC leakfilename = malloc( strlen( progname ) + STRLENOF( ".leak" ) + 1 ); sprintf( leakfilename, "%s.leak", progname ); @@ -245,11 +251,12 @@ slap_tool_init( break; case 'd': /* turn on debugging */ + { #ifdef LDAP_DEBUG + int level; + if ( optarg != NULL && optarg[ 0 ] != '-' && !isdigit( optarg[ 0 ] ) ) { - int level; - if ( str2loglevel( optarg, &level ) ) { fprintf( stderr, "unrecognized log level " @@ -257,10 +264,7 @@ slap_tool_init( exit( EXIT_FAILURE ); } - ldap_debug |= level; - } else { - int level; char *next = NULL; level = strtol( optarg, &next, 0 ); @@ -270,14 +274,20 @@ slap_tool_init( "\"%s\"\n", optarg ); exit( EXIT_FAILURE ); } + } + + if ( level ) { ldap_debug |= level; + } else { + /* allow to reset log level */ + ldap_debug = 0; } #else if ( atoi( optarg ) != 0 ) fputs( "must compile with LDAP_DEBUG for debugging\n", stderr ); #endif - break; + } break; case 'D': ber_str2bv( optarg, 0, 1, &authcDN ); -- 2.39.5