]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: provide more information in case of failed LOOKUP.
authorDmitrij Tejblum <tejblum@yandex-team.ru>
Wed, 21 Sep 2011 13:41:41 +0000 (17:41 +0400)
committerDenis Ovsienko <infrastation@yandex.ru>
Tue, 27 Sep 2011 17:45:53 +0000 (21:45 +0400)
* log.[ch]
  * mes_lookup: add a parameter with the name of the message list, print
    the name in case of failure.
  * LOOKUP macro: pass the name of the message list.

lib/log.c
lib/log.h

index 8a7e5f3a7d4eaed9ddee70cfb02cb9497f18cdbe..4afe922906f94ff048253d838ddf571ed1b9c72a 100644 (file)
--- a/lib/log.c
+++ b/lib/log.c
@@ -774,7 +774,8 @@ lookup (const struct message *mes, int key)
  * provided otherwise.
  */
 const char *
-mes_lookup (const struct message *meslist, int max, int index, const char *none)
+mes_lookup (const struct message *meslist, int max, int index,
+  const char *none, const char *mesname)
 {
   int pos = index - meslist[0].key;
   
@@ -797,13 +798,13 @@ mes_lookup (const struct message *meslist, int max, int index, const char *none)
          {
            const char *str = (meslist->str ? meslist->str : none);
            
-           zlog_debug ("message index %d [%s] found in position %d (max is %d)",
-                     index, str, i, max);
+           zlog_debug ("message index %d [%s] found in %s at position %d (max is %d)",
+                     index, str, mesname, i, max);
            return str;
          }
       }
   }
-  zlog_err("message index %d not found (max is %d)", index, max);
+  zlog_err("message index %d not found in %s (max is %d)", index, mesname, max);
   assert (none);
   return none;
 }
index 1f9a68992e95f7407f4bf0ed555e70ac1e27cb39..ee34a4ad2d9dab986ae87caba0aff32f7540e0a9 100644 (file)
--- a/lib/log.h
+++ b/lib/log.h
@@ -146,12 +146,12 @@ extern int zlog_reset_file (struct zlog *zl);
 extern int zlog_rotate (struct zlog *);
 
 /* For hackey massage lookup and check */
-#define LOOKUP(x, y) mes_lookup(x, x ## _max, y, "(no item found)")
+#define LOOKUP(x, y) mes_lookup(x, x ## _max, y, "(no item found)", #x)
 
 extern const char *lookup (const struct message *, int);
 extern const char *mes_lookup (const struct message *meslist, 
                                int max, int index,
-                               const char *no_item);
+                               const char *no_item, const char *mesname);
 
 extern const char *zlog_priority[];
 extern const char *zlog_proto_names[];