From: sibaz Date: Sat, 24 Aug 2002 03:47:37 +0000 (+0000) Subject: doh, the code was looking up the loglevel against a table, then using the position... X-Git-Tag: point-did-cleanup~49 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=netatalk.git;a=commitdiff_plain;h=e7af0b9ab4e04a257c8ab29cd3facefd50c8bd00 doh, the code was looking up the loglevel against a table, then using the position in that table as the value, the enum was ten times that. That was all that was causing problems. I've altered the loglevels table to reflect this, by making the more debug levels go debug, debug6, debug7, debug8, debug9, maxdebug, all of which correspond to their enum values except divided by ten --- diff --git a/config/afpd.conf.tmpl b/config/afpd.conf.tmpl index 041dd7d1..c1c09383 100644 --- a/config/afpd.conf.tmpl +++ b/config/afpd.conf.tmpl @@ -143,7 +143,8 @@ # the same logtype (file or syslog). # logtypes: Default, Core, Logger, CNID, AFPDaemon # loglevels: LOG_SEVERE, LOG_ERROR, LOG_WARN, LOG_NOTE, -# LOG_INFO, LOG_DEBUG, LOG_EXTRADEBUG +# LOG_INFO, LOG_DEBUG, LOG_DEBUG6, LOG_DEBUG7, +# LOG_DEBUG8, LOG_DEBUG9, LOG_MAXDEBUG # # Some examples: # diff --git a/include/atalk/logger.h b/include/atalk/logger.h index 61f5125b..dbcc7867 100644 --- a/include/atalk/logger.h +++ b/include/atalk/logger.h @@ -17,7 +17,11 @@ enum loglevels { log_note = 30, log_info = 40, log_debug = 50, - log_extradebug= 60 + log_debug6 = 60, + log_debug7 = 70, + log_debug8 = 80, + log_debug9 = 90, + log_maxdebug = 100 }; #define LOGLEVEL_STRING_IDENTIFIERS { \ "LOG_SEVERE", \ @@ -26,7 +30,11 @@ enum loglevels { "LOG_NOTE", \ "LOG_INFO", \ "LOG_DEBUG", \ - "LOG_EXTRADEBUG"} + "LOG_DEBUG6", \ + "LOG_DEBUG7", \ + "LOG_DEBUG8", \ + "LOG_DEBUG9", \ + "LOG_MAXDEBUG"} /* this is the enum specifying all availiable logtypes */ enum logtypes { diff --git a/libatalk/util/logger.c b/libatalk/util/logger.c index a79e4cf6..b3a1f146 100644 --- a/libatalk/util/logger.c +++ b/libatalk/util/logger.c @@ -230,7 +230,11 @@ bool log_setup(char *filename, enum loglevels loglevel, enum logtypes logtype, log_init(); logs = log_file_arr[logtype]; + + LOG(log_debug6, logtype_logger, "doing log_setup, type %d, level %d, filename \"%s\"", logtype, loglevel, filename); + /* LOG(log_extradebug+10, logtype_logger, "checking array for logtype is malloc'd"); */ + /* has the given logtype already been assigned memory? */ if (logs==NULL) { logs = (log_file_data_pair *)malloc(sizeof(log_file_data_pair)); @@ -248,12 +252,14 @@ bool log_setup(char *filename, enum loglevels loglevel, enum logtypes logtype, } } + /* I think this checks if we're logging to stdout or not. Probably unused */ if ( ((*logs)[1].log_file == stdout) && ((*logs)[1].log_file != NULL) ) { fclose((*logs)[1].log_file); (*logs)[1].log_file = NULL; } + /* check if we need to append the given filename to a directory */ if (strlen(global_log_data.log_file_directory)>0) { lastchar[0] = global_log_data. @@ -363,6 +369,9 @@ bool log_setup(char *filename, enum loglevels loglevel, enum logtypes logtype, } #endif + LOG(log_debug7, logtype_logger, "log_file_arr[%d] now contains: " + "{log_filename:%s, log_file:%p, log_level: %d}", logtype, + (*logs)[1].log_filename, (*logs)[1].log_file, (*logs)[1].log_level); LOG(log_info, logtype_logger, "Log setup complete"); #endif /* DISABLE_LOGGER */ @@ -875,8 +884,7 @@ int get_syslog_equivalent(enum loglevels loglevel) void setuplog(char *logtype, char *loglevel, char *filename) { #ifndef DISABLE_LOGGER - /* -setuplogtype */ - /* -setuplogtype []*/ + /* -[un]setuplog []*/ /* This should be rewritten so that somehow logsource is assumed and everything can be taken from default if needs be. @@ -890,48 +898,9 @@ void setuplog(char *logtype, char *loglevel, char *filename) LOG(log_extradebug, logtype_logger, "Attempting setuplog: %s %s %s %s", logsource, logtype, loglevel, filename); */ - LOG(log_extradebug, logtype_logger, "Attempting setuplog: %s %s %s", + LOG(log_debug6, logtype_logger, "Attempting setuplog: %s %s %s", logtype, loglevel, filename); - /* - Do I need these? - - if (logsource==NULL) - logsource=null; - if (logtype==NULL) - logtype=null; - if (loglevel==NULL) - loglevel=null; - if (filename==NULL) - filename=null; - */ - - /* - * We'll just use filename, if its NULL we know its a syslog thing - * - if (logsource==NULL) - { - LOG(log_note, logtype_logger, "no logsource given"); - } - else - { - for(sourcenum=0;sourcenum=NUMOF(sources)) - { - LOG(log_warning, logtype_logger, "%s is not a valid log source", logsource); - } - if ((sourcenum>0) && (filename==NULL)) - { - LOG(log_warning, logtype_logger, - "when specifying a filelog, you must specify a valid filename"); - } - } - */ - if (logtype==NULL) { LOG(log_note, logtype_logger, "no logsource given"); @@ -976,6 +945,9 @@ void setuplog(char *logtype, char *loglevel, char *filename) return; } + /* now match the order of the text string with the actual enum value (10 times) */ + levelnum*=10; + /* is this a syslog setup or a filelog setup */ if (filename==NULL) /* must be syslog */ {