From b2b93885c080c8d9634bbc4af33b16bbf3e3e946 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1=D1?=
 =?UTF-8?q?=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= <lrn1986@gmail.com>
Date: Sat, 1 Oct 2011 23:06:06 +0400
Subject: [PATCH 4/5] Make sure that defaults aren't used when there are
 matching logdefs

---
 src/util/common_logging.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/util/common_logging.c b/src/util/common_logging.c
index 06f5f76..bbfd092 100644
--- a/src/util/common_logging.c
+++ b/src/util/common_logging.c
@@ -228,6 +228,7 @@ get_log_call_status (int caller_level, const char *comp, const char *file, const
   int i;
   int force_only;
   size_t strlen_file;
+  int matches = 0;
   if (comp == NULL)
     comp = component_nopid;
   if (min_level >= 0 && gnunet_force_log_present == GNUNET_NO)
@@ -238,7 +239,6 @@ get_log_call_status (int caller_level, const char *comp, const char *file, const
   {
     ld = &logdefs[i];
     if ((!force_only || ld->force) &&
-        (caller_level <= ld->level) &&
         (line >= ld->from_line && line <= ld->to_line) &&
         (ld->component == NULL || strcmp (comp, ld->component) == 0) &&
         (ld->file == NULL ||
@@ -247,9 +247,15 @@ get_log_call_status (int caller_level, const char *comp, const char *file, const
         (ld->function == NULL || strcmp (function, ld->function) == 0)
        )
     {
-      return 1;
+      matches += 1;
+      if (caller_level <= ld->level)
+        return 1;
     }
   }
+  /* If some rules did match, but had too low loglevel to allow logging, don't check any further */
+  if (matches > 0)
+    return 0;
+  /* Otherwise use global level, if defined */
   if (min_level >= 0)
     return caller_level <= min_level;
   /* All programs/services previously defaulted to WARNING.
-- 
1.7.4

