]> git.sur5r.net Git - openldap/commitdiff
Reparse unknown debug flags after config is read to allow use
authorHoward Chu <hyc@openldap.org>
Thu, 2 Feb 2006 08:30:56 +0000 (08:30 +0000)
committerHoward Chu <hyc@openldap.org>
Thu, 2 Feb 2006 08:30:56 +0000 (08:30 +0000)
of dynamically registered debug levels

servers/slapd/bconfig.c
servers/slapd/main.c
servers/slapd/proto-slap.h
servers/slapd/slapcommon.c

index 3d3771b838df86ebf92e2d0e77fb966ebf888561..a5cf6730cf54bac7c2a007902431112bbbd9e533 100644 (file)
@@ -2171,7 +2171,7 @@ slap_loglevel_get( struct berval *s, int *l )
        rc = slap_verbmasks_append( &loglevel_ops, i, s, loglevel_ignore );
 
        if ( rc != 0 ) {
-               Debug( LDAP_DEBUG_ANY, "slap_loglevel_register(%lu, \"%s\") failed\n",
+               Debug( LDAP_DEBUG_ANY, "slap_loglevel_get(%lu, \"%s\") failed\n",
                        i, s->bv_val, 0 );
 
        } else {
index 38348533d4d698249e23701ab9672dbb75df384f..46d24ba1dbf8dad8bbddfa0935938832cfba694b 100644 (file)
@@ -222,13 +222,31 @@ parse_syslog_level( const char *arg, int *levelp )
 }
 
 int
-parse_debug_level( const char *arg, int *levelp )
+parse_debug_unknowns( char **unknowns, int *levelp )
+{
+       int i, level, rc = 0;
+
+       for ( i = 0; unknowns[ i ] != NULL; i++ ) {
+               level = 0;
+               if ( str2loglevel( unknowns[ i ], &level )) {
+                       fprintf( stderr,
+                               "unrecognized log level \"%s\"\n", unknowns[ i ] );
+                       rc = 1;
+               } else {
+                       *levelp |= level;
+               }
+       }
+       return rc;
+}
+
+int
+parse_debug_level( const char *arg, int *levelp, char ***unknowns )
 {
        int     level;
 
        if ( arg != NULL && arg[ 0 ] != '-' && !isdigit( arg[ 0 ] ) )
        {
-               int     i, goterr = 0;
+               int     i;
                char    **levels;
 
                levels = ldap_str2charray( arg, "," );
@@ -237,12 +255,11 @@ parse_debug_level( const char *arg, int *levelp )
                        level = 0;
 
                        if ( str2loglevel( levels[ i ], &level ) ) {
+                               /* remember this for later */
+                               ldap_charray_add( unknowns, levels[ i ] );
                                fprintf( stderr,
-                                       "unrecognized log level "
-                                       "\"%s\"\n", levels[ i ] );
-                               goterr = 1;
-                               /* but keep parsing... */
-
+                                       "unrecognized log level \"%s\" (deferred)\n",
+                                       levels[ i ] );
                        } else {
                                *levelp |= level;
                        }
@@ -250,10 +267,6 @@ parse_debug_level( const char *arg, int *levelp )
 
                ldap_charray_free( levels );
 
-               if ( goterr ) {
-                       return 1;
-               }
-
        } else {
                if ( lutil_atoix( &level, arg, 0 ) != 0 ) {
                        fprintf( stderr,
@@ -349,6 +362,9 @@ int main( int argc, char **argv )
        struct sync_cookie *scp = NULL;
        struct sync_cookie *scp_entry = NULL;
 
+       char **debug_unknowns = NULL;
+       char **syslog_unknowns = NULL;
+
        char *serverNamePrefix = "";
        size_t  l;
 
@@ -486,7 +502,7 @@ int main( int argc, char **argv )
                        int     level = 0;
 
                        no_detach = 1;
-                       if ( parse_debug_level( optarg, &level ) ) {
+                       if ( parse_debug_level( optarg, &level, &debug_unknowns ) ) {
                                goto destroy;
                        }
 #ifdef LDAP_DEBUG
@@ -541,7 +557,7 @@ int main( int argc, char **argv )
                }
 
                case 's':       /* set syslog level */
-                       if ( parse_debug_level( optarg, &ldap_syslog ) ) {
+                       if ( parse_debug_level( optarg, &ldap_syslog, &syslog_unknowns ) ) {
                                goto destroy;
                        }
                        break;
@@ -707,6 +723,21 @@ unhandled_option:;
                goto destroy;
        }
 
+       if ( debug_unknowns ) {
+               rc = parse_debug_unknowns( debug_unknowns, &slap_debug );
+               ldap_charray_free( debug_unknowns );
+               debug_unknowns = NULL;
+               if ( rc )
+                       goto destroy;
+       }
+       if ( syslog_unknowns ) {
+               rc = parse_debug_unknowns( syslog_unknowns, &ldap_syslog );
+               ldap_charray_free( syslog_unknowns );
+               syslog_unknowns = NULL;
+               if ( rc )
+                       goto destroy;
+       }
+
        if ( check & CHECK_CONFIG ) {
                fprintf( stderr, "config check succeeded\n" );
 
index 5859ecad3e045b659b47ee288e5ab82797363e30..5bdba47717cc3b10f82c46dc12beadf81013df78 100644 (file)
@@ -1004,7 +1004,9 @@ LDAP_SLAPD_F (int) lock_fclose LDAP_P(( FILE *fp, FILE *lfp ));
  * main.c
  */
 LDAP_SLAPD_F (int)
-parse_debug_level LDAP_P(( const char *arg, int *levelp ));
+parse_debug_level LDAP_P(( const char *arg, int *levelp, char ***unknowns ));
+LDAP_SLAPD_F (int)
+parse_debug_unknowns LDAP_P(( char **unknowns, int *levelp ));
 
 /*
  * matchedValues.c
index 9f99363dc8aa0d39a4f98717d1a1ea83504106dd..59e1e01cf359190006c5d6b693584f285daa120d 100644 (file)
@@ -189,6 +189,7 @@ slap_tool_init(
        char *filterstr = NULL;
        char *subtree = NULL;
        char *ldiffile  = NULL;
+       char **debug_unknowns = NULL;
        int rc, i, dbnum;
        int mode = SLAP_TOOL_MODE;
        int truncatemode = 0;
@@ -267,7 +268,7 @@ slap_tool_init(
                case 'd': {     /* turn on debugging */
                        int     level = 0;
 
-                       if ( parse_debug_level( optarg, &level ) ) {
+                       if ( parse_debug_level( optarg, &level, &debug_unknowns ) ) {
                                usage( tool, progname );
                        }
 #ifdef LDAP_DEBUG
@@ -454,6 +455,14 @@ slap_tool_init(
                exit( EXIT_FAILURE );
        }
 
+       if ( debug_unknowns ) {
+               rc = parse_debug_unknowns( debug_unknowns, &slap_debug );
+               ldap_charray_free( debug_unknowns );
+               debug_unknowns = NULL;
+               if ( rc )
+                       exit( EXIT_FAILURE );
+       }
+
        at_oc_cache = 1;
 
        switch ( tool ) {