X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Flog.c;h=ecdb45819a78c20bfad66b6141adfaa95970d1a0;hb=a94620ffd6001681474a94f5de767f168d772d1c;hp=024982b50ecc258fe49a7c7597e4c41c7c43d224;hpb=5d309bb5cfcf1fd46efb31c6d240aeb36fc915b5;p=yaz-moved-to-github.git diff --git a/src/log.c b/src/log.c index 024982b..ecdb458 100644 --- a/src/log.c +++ b/src/log.c @@ -2,7 +2,7 @@ * Copyright (c) 1995-2004, Index Data * See the file LICENSE for details. * - * $Id: log.c,v 1.12 2004-11-04 14:19:58 heikki Exp $ + * $Id: log.c,v 1.15 2004-11-17 13:03:07 heikki Exp $ */ /** @@ -35,7 +35,6 @@ #include #include #include -#include static NMEM_MUTEX log_mutex = 0; static int mutex_init_flag = 0; /* not yet initialized */ @@ -89,6 +88,7 @@ static struct { { LOG_APP3, "app3" }, { LOG_ALL, "all" }, { LOG_FLUSH, "flush" }, + { LOG_LOGLVL, "loglevel" }, { 0, "none" }, { 0, NULL } /* the rest will be filled in if the user defines dynamic modules*/ @@ -156,6 +156,7 @@ static void rotate_log() newname[509] = '\0'; /* make sure it is terminated */ strcat(newname,".1"); #ifdef WIN32 + /* windows can't rename a file if it is open */ fclose(l_file); l_file = stderr; #endif @@ -172,6 +173,22 @@ void yaz_log_init_level (int level) yaz_log_reopen(); /* make sure we set buffering right */ } else l_level = level; + if (l_level & LOG_LOGLVL) + { /* dump the log level bits */ + char *bittype="Static "; + int i; + yaz_log(LOG_LOGLVL,"Setting log level to %d = 0x%08x",l_level,l_level); + for (i = 0; mask_names[i].name; i++) + if (mask_names[i].mask && *mask_names[i].name) + if (strcmp(mask_names[i].name,"all")!=0) + { + yaz_log(LOG_LOGLVL,"%s log bit %08x '%s' is %s", + bittype, mask_names[i].mask, mask_names[i].name, + (level & mask_names[i].mask)? "ON": "off"); + if (mask_names[i].mask>LOG_LAST_BIT) + bittype="Dynamic"; + } + } } void yaz_log_init_prefix (const char *prefix) @@ -320,19 +337,16 @@ void yaz_log_time_format(const char *fmt) /** cleans a loglevel name from leading paths and suffixes */ static char *clean_name(const char *name, int len, char *namebuf, int buflen) { - char *p; - char *start; + char *p = namebuf; + char *start = namebuf; if (buflen