]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
allow (and use) symbolic names for syslog levels
authorPierangelo Masarati <ando@openldap.org>
Mon, 19 Dec 2005 22:55:30 +0000 (22:55 +0000)
committerPierangelo Masarati <ando@openldap.org>
Mon, 19 Dec 2005 22:55:30 +0000 (22:55 +0000)
doc/man/man8/slapd.8
servers/slapd/main.c
tests/scripts/defines.sh

index 015905ad18f277533850ae29c2b8a534c39200eb..bb55fe7174e4ab86a9743ddc85907f52e877d3a9 100644 (file)
@@ -96,6 +96,16 @@ This option tells
 at what level debugging statements should be logged to the
 .BR syslog (8)
 facility.
+The value can be any of
+"EMERG",
+"ALERT",
+"CRIT",
+"ERR",
+"WARNING",
+"NOTICE",
+"INFO" or
+"DEBUG",
+defaulting to "DEBUG".
 .TP
 .BI \-n " service\-name"
 Specifies the service name for logging and other purposes.  Defaults
index f9dd88d893c71b4d5b41359565ee3d85e3d13a53..bd58a36edc733577bc2d78c27bd7a1fd0497f899 100644 (file)
@@ -483,8 +483,32 @@ int main( int argc, char **argv )
                }
 
                case 's':       /* set syslog level */
-                       if ( lutil_atoi( &ldap_syslog_level, optarg ) != 0 ) {
-                               fprintf( stderr, "unable to parse syslog level \"%s\"", optarg );
+                       if ( !isdigit( optarg[ 0 ] ) ) {
+                               slap_verbmasks  str2syslog_level[] = {
+                                       { BER_BVC( "EMERG" ),   LOG_EMERG },
+                                       { BER_BVC( "ALERT" ),   LOG_ALERT },
+                                       { BER_BVC( "CRIT" ),    LOG_CRIT },
+                                       { BER_BVC( "ERR" ),     LOG_ERR },
+                                       { BER_BVC( "WARNING" ), LOG_WARNING },
+                                       { BER_BVC( "NOTICE" ),  LOG_NOTICE },
+                                       { BER_BVC( "INFO" ),    LOG_INFO },
+                                       { BER_BVC( "DEBUG" ),   LOG_DEBUG },
+                                       { BER_BVNULL, 0 }
+                               };
+                               int i = verb_to_mask( optarg, str2syslog_level );
+                               if ( BER_BVISNULL( &str2syslog_level[ i ].word ) ) {
+                                       Debug( LDAP_DEBUG_ANY,
+                                               "unknown syslog level \"%s\".\n",
+                                               optarg, 0, 0 );
+                                       goto destroy;
+                               }
+               
+                               ldap_syslog_level = str2syslog_level[ i ].mask;
+
+                       } else if ( lutil_atoi( &ldap_syslog_level, optarg ) != 0 ) {
+                               Debug( LDAP_DEBUG_ANY,
+                                       "unable to parse syslog level \"%s\".\n",
+                                       optarg, 0, 0 );
                                goto destroy;
                        }
                        break;
index 170b23a720d8bbfa0896335a11660f5bf4d9a65a..58a33bc1e665643e2e367b387ffe867411275812 100755 (executable)
@@ -137,7 +137,7 @@ DIFF="diff -i"
 CMP="diff -i"
 BCMP="diff -iB"
 CMPOUT=/dev/null
-SLAPD="../servers/slapd/slapd -s0"
+SLAPD="../servers/slapd/slapd -sDEBUG"
 SLURPD=../servers/slurpd/slurpd
 LDAPPASSWD="$CLIENTDIR/ldappasswd $TOOLARGS"
 LDAPSASLSEARCH="$CLIENTDIR/ldapsearch $TOOLPROTO $LDAP_TOOLARGS -LLL"