From 5a541e87446eed445674a72dfb055e531c6ab53c Mon Sep 17 00:00:00 2001 From: Gary Williams Date: Tue, 17 Oct 2000 18:56:24 +0000 Subject: [PATCH] convert string levels to ints --- libraries/liblutil/debug.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/libraries/liblutil/debug.c b/libraries/liblutil/debug.c index 871ef54da8..1e3a51f8b5 100644 --- a/libraries/liblutil/debug.c +++ b/libraries/liblutil/debug.c @@ -51,6 +51,25 @@ static long numLevels = 0; int global_level = 0; +static char *lutil_levels[] = {"emergency", "alert", "critical", + "error", "warning", "notice", + "information", "entry", "args", + "results", "detail1", "detail2", + NULL}; + +int lutil_mnem2level( char *level ) +{ + int i; + for( i = 0; lutil_levels[i] != NULL; i++ ) + { + if ( !strcasecmp( level, lutil_levels[i] ) ) + { + return i; + } + } + return 0; +} + static void addSubsys( const char *subsys, int level ) { int i, j; @@ -103,6 +122,7 @@ void lutil_log_int(FILE* file, char *subsys, int level, const char *fmt, va_list struct tm *today; int i; + if ( levelArray == NULL ) return; /* logging isn't set up */ /* * Look for the subsystem in the level array. When we find it, break out of the * loop. @@ -232,14 +252,13 @@ void lutil_log_initialize(int argc, char **argv) *index = 0; strcpy ( subsys, optarg ); level = atoi( index+1 ); + if ( level <= 0 ) level = lutil_mnem2level( index + 1 ); lutil_set_debug_level( subsys, level ); - printf( "setting debug level of %s to %d\n", subsys, level ); *index = '='; } else { global_level = atoi( optarg ); - printf( "setting global level to %d\n", global_level ); } } } -- 2.39.5