From: Pierangelo Masarati Date: Fri, 8 Sep 2006 18:10:53 +0000 (+0000) Subject: re-enable "-d '?'" as a means to list what loglevels are available (ITS#4666) X-Git-Tag: OPENLDAP_REL_ENG_2_3_MP~193 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c3f9d6802712140407ec44723d976e6baad75c1e;p=openldap re-enable "-d '?'" as a means to list what loglevels are available (ITS#4666) --- diff --git a/servers/slapd/bconfig.c b/servers/slapd/bconfig.c index efde6ef36c..0ed3bc41b6 100644 --- a/servers/slapd/bconfig.c +++ b/servers/slapd/bconfig.c @@ -2358,6 +2358,28 @@ loglevel2bvarray( int l, BerVarray *bva ) return mask_to_verbs( loglevel_ops, l, bva ); } +int +loglevel_print( FILE *out ) +{ + int i; + + if ( loglevel_ops == NULL ) { + loglevel_init(); + } + + fprintf( out, "Installed log subsystems:\n\n" ); + for ( i = 0; !BER_BVISNULL( &loglevel_ops[ i ].word ); i++ ) { + fprintf( out, "\t%-30s (%d)\n", + loglevel_ops[ i ].word.bv_val, + loglevel_ops[ i ].mask ); + } + + fprintf( out, "\nNOTE: custom log subsystems may be later installed " + "by specific code\n\n" ); + + return 0; +} + static int config_syslog; static int diff --git a/servers/slapd/main.c b/servers/slapd/main.c index c7036fae5c..8b1ee9c9c6 100644 --- a/servers/slapd/main.c +++ b/servers/slapd/main.c @@ -501,6 +501,11 @@ int main( int argc, char **argv ) case 'd': { /* set debug level and 'do not detach' flag */ int level = 0; + if ( strcmp( optarg, "?" ) == 0 ) { + rc = loglevel_print( stdout ); + goto destroy; + } + no_detach = 1; if ( parse_debug_level( optarg, &level, &debug_unknowns ) ) { goto destroy; @@ -557,6 +562,11 @@ int main( int argc, char **argv ) } case 's': /* set syslog level */ + if ( strcmp( optarg, "?" ) == 0 ) { + rc = loglevel_print( stdout ); + goto destroy; + } + if ( parse_debug_level( optarg, &ldap_syslog, &syslog_unknowns ) ) { goto destroy; } diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 4ca9f1dd2a..7f91c961cf 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -429,6 +429,7 @@ LDAP_SLAPD_F (int) str2loglevel LDAP_P(( const char *s, int *l )); LDAP_SLAPD_F (int) loglevel2bvarray LDAP_P(( int l, BerVarray *bva )); LDAP_SLAPD_F (const char *) loglevel2str LDAP_P(( int l )); LDAP_SLAPD_F (int) loglevel2bv LDAP_P(( int l, struct berval *bv )); +LDAP_SLAPD_F (int) loglevel_print LDAP_P(( FILE *out )); LDAP_SLAPD_F (int) slap_cf_aux_table_parse LDAP_P(( const char *word, void *bc, slap_cf_aux_table *tab0, LDAP_CONST char *tabmsg )); LDAP_SLAPD_F (int) slap_cf_aux_table_unparse LDAP_P(( void *bc, struct berval *bv, slap_cf_aux_table *tab0 ));