X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Flog.c;h=ecdb45819a78c20bfad66b6141adfaa95970d1a0;hb=a94620ffd6001681474a94f5de767f168d772d1c;hp=4ee727cb27086a56550d0cd92dabfe5a884d06e7;hpb=3dc194a876fec3eeb9623f7a14cabf7eb0b4a2dc;p=yaz-moved-to-github.git diff --git a/src/log.c b/src/log.c index 4ee727c..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.11 2004-11-03 22:33:17 adam 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) @@ -258,8 +275,10 @@ void yaz_log(int level, const char *fmt, ...) { if (*mask_names[i].name && mask_names[i].mask && mask_names[i].mask != LOG_ALL) + { sprintf(flags + strlen(flags), "[%s]", mask_names[i].name); - level -= mask_names[i].mask; + level &= ~mask_names[i].mask; + } } va_start(ap, fmt); #ifdef WIN32 @@ -318,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