From a94620ffd6001681474a94f5de767f168d772d1c Mon Sep 17 00:00:00 2001 From: Heikki Levanto Date: Wed, 17 Nov 2004 13:03:07 +0000 Subject: [PATCH] Added an option to specify -word in the loglevel parsing, to clear a specific bit: -v all,-log --- doc/tools.xml | 7 ++++--- src/log.c | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/doc/tools.xml b/doc/tools.xml index cf77afc..01fb2c5 100644 --- a/doc/tools.xml +++ b/doc/tools.xml @@ -1,4 +1,4 @@ - + Supporting Tools @@ -1850,8 +1850,9 @@ typedef struct oident logged. This string should be a comma-separated list of log level names, and can contain both hard-coded names and dynamic ones. The log level calculation starts with LOG_DEFAULT_LEVEL and adds a bit - for each word it meets. If the string 'none' is found, - the bits are cleared. Typically this string comes from the command-line, + for each word it meets, unless the word starts with a '-', in which case it + clears the bit. If the string 'none' is found, + all bits are cleared. Typically this string comes from the command-line, often identified by -v. The yaz_log_mask_str returns a log level that should be passed to yaz_log_init_level for it to take effect. diff --git a/src/log.c b/src/log.c index d8a3652..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.14 2004-11-16 17:08:11 heikki Exp $ + * $Id: log.c,v 1.15 2004-11-17 13:03:07 heikki Exp $ */ /** @@ -397,15 +397,22 @@ int yaz_log_mask_str_x (const char *str, int level) const char *p; int i; int found; + int negated; char clean[255] = ""; char *n = clean; while (*str) { found = 0; + negated=0; for (p = str; *p && *p != ','; p++) ; - if (*str == '-' || isdigit(*str)) + if (*str=='-') + { + negated=1; + str++; + } + if (isdigit(*str)) { level = atoi (str); found = 1; @@ -417,7 +424,10 @@ int yaz_log_mask_str_x (const char *str, int level) if (0==strcmp (mask_names[i].name,n)) { if (mask_names[i].mask) - level |= mask_names[i].mask; + if (negated) + level &= ~mask_names[i].mask; + else + level |= mask_names[i].mask; else level = 0; /* 'none' clears them all */ found = 1; -- 1.7.10.4