BIND 10 trac745, updated. b92cca798d702273d63d56d9197782edeb927c8c [trac745] Add first few messages

BIND 10 source code commits bind10-changes at lists.isc.org
Thu Apr 28 09:21:33 UTC 2011


The branch, trac745 has been updated
       via  b92cca798d702273d63d56d9197782edeb927c8c (commit)
       via  abdf624576745fa0a4f37319e3c7dbd76047e2d2 (commit)
      from  87e4b9874ac16ccc5d236a2fcb8221942713e086 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit b92cca798d702273d63d56d9197782edeb927c8c
Author: Stephen Morris <stephen at isc.org>
Date:   Thu Apr 28 10:19:01 2011 +0100

    [trac745] Add first few messages
    
    In addition, run_unittests.cc has been augmented by some temporary
    code to enable message output during testing.  This code is likely
    to change or to be moved to a utility directory at some point in
    the future.

commit abdf624576745fa0a4f37319e3c7dbd76047e2d2
Author: Stephen Morris <stephen at isc.org>
Date:   Thu Apr 28 10:17:36 2011 +0100

    [trac745] Add message definitions
    
    Note that nsasdef.cc and nsasdef.h are derived from nsasdef.msg and
    really should be generated from it during the build process.  For now
    though, they are generated and added to the git repository.

-----------------------------------------------------------------------

Summary of changes:
 src/lib/nsas/Makefile.am                           |    5 ++
 src/lib/nsas/nameserver_address_store.cc           |   12 ++++
 .../tests/run_unittests.cc => nsas/nsas_levels.h}  |   17 +++---
 src/lib/nsas/nsasdef.cc                            |   27 ++++++++
 src/lib/nsas/nsasdef.h                             |   17 +++++
 .../bindctl/setup.sh => src/lib/nsas/nsasdef.msg   |   18 +++---
 src/lib/nsas/tests/Makefile.am                     |    1 +
 src/lib/nsas/tests/run_unittests.cc                |   64 ++++++++++++++++++++
 8 files changed, 142 insertions(+), 19 deletions(-)
 copy src/lib/{server_common/tests/run_unittests.cc => nsas/nsas_levels.h} (71%)
 create mode 100644 src/lib/nsas/nsasdef.cc
 create mode 100644 src/lib/nsas/nsasdef.h
 copy tests/system/bindctl/setup.sh => src/lib/nsas/nsasdef.msg (68%)
 mode change 100755 => 100644

-----------------------------------------------------------------------
diff --git a/src/lib/nsas/Makefile.am b/src/lib/nsas/Makefile.am
index 5f05f1b..7ffc61d 100644
--- a/src/lib/nsas/Makefile.am
+++ b/src/lib/nsas/Makefile.am
@@ -4,6 +4,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
 AM_CPPFLAGS += $(BOOST_INCLUDES) $(MULTITHREADING_FLAG)
 AM_CPPFLAGS += -I$(top_srcdir)/src/lib/dns -I$(top_builddir)/src/lib/dns
 AM_CPPFLAGS += -I$(top_srcdir)/src/lib/util -I$(top_builddir)/src/lib/util
+AM_CPPFLAGS += -I$(top_srcdir)/src/lib/log -I$(top_builddir)/src/lib/log
 AM_CPPFLAGS += -I$(top_srcdir)/src/lib/nsas -I$(top_builddir)/src/lib/nsas
 AM_CPPFLAGS += $(SQLITE_CFLAGS)
 AM_CXXFLAGS = $(B10_CXXFLAGS)
@@ -30,11 +31,15 @@ libnsas_la_SOURCES += hash_table.h
 libnsas_la_SOURCES += nameserver_address_store.cc nameserver_address_store.h
 libnsas_la_SOURCES += nameserver_address.h nameserver_address.cc
 libnsas_la_SOURCES += nameserver_entry.cc nameserver_entry.h
+libnsas_la_SOURCES += nsasdef.h nsasdef.cc
 libnsas_la_SOURCES += nsas_entry_compare.h
 libnsas_la_SOURCES += nsas_entry.h nsas_types.h
+libnsas_la_SOURCES += nsas_levels.h
 libnsas_la_SOURCES += zone_entry.cc zone_entry.h
 libnsas_la_SOURCES += fetchable.h
 libnsas_la_SOURCES += address_request_callback.h
 libnsas_la_SOURCES += glue_hints.h glue_hints.cc
 
+EXTRA_DIST = nsasdef.msg
+
 CLEANFILES = *.gcno *.gcda
diff --git a/src/lib/nsas/nameserver_address_store.cc b/src/lib/nsas/nameserver_address_store.cc
index 3cef38d..816ad8f 100644
--- a/src/lib/nsas/nameserver_address_store.cc
+++ b/src/lib/nsas/nameserver_address_store.cc
@@ -22,6 +22,7 @@
 #include <dns/rdataclass.h>
 #include <util/locks.h>
 #include <util/lru_list.h>
+#include <log/logger.h>
 
 #include "hash_table.h"
 #include "hash_deleter.h"
@@ -31,6 +32,8 @@
 #include "zone_entry.h"
 #include "glue_hints.h"
 #include "address_request_callback.h"
+#include "nsasdef.h"
+#include "nsas_levels.h"
 
 using namespace isc::dns;
 using namespace std;
@@ -38,6 +41,11 @@ using namespace std;
 namespace isc {
 namespace nsas {
 
+// Define logger for messages (local to this file)
+namespace {
+isc::log::Logger logger("nsas");
+}
+
 // Constructor.
 //
 // The LRU lists are set equal to three times the size of the respective
@@ -84,6 +92,8 @@ NameserverAddressStore::lookup(const string& zone, const RRClass& class_code,
     boost::shared_ptr<AddressRequestCallback> callback, AddressFamily family,
     const GlueHints& glue_hints)
 {
+    logger.debug(NSAS_DBG_TRACE, NSAS_LOOKUPZONE, zone.c_str());
+
     pair<bool, boost::shared_ptr<ZoneEntry> > zone_obj(
         zone_hash_->getOrAdd(HashKey(zone, class_code),
                              boost::bind(newZone, resolver_, &zone, &class_code,
@@ -103,6 +113,8 @@ NameserverAddressStore::cancel(const string& zone,
     const boost::shared_ptr<AddressRequestCallback>& callback,
     AddressFamily family)
 {
+    logger.debug(NSAS_DBG_TRACE, NSAS_LOOKUPCANCEL, zone.c_str());
+
     boost::shared_ptr<ZoneEntry> entry(zone_hash_->get(HashKey(zone,
                                                                class_code)));
     if (entry) {
diff --git a/src/lib/nsas/nsas_levels.h b/src/lib/nsas/nsas_levels.h
new file mode 100644
index 0000000..3688443
--- /dev/null
+++ b/src/lib/nsas/nsas_levels.h
@@ -0,0 +1,25 @@
+// Copyright (C) 2011  Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#ifndef __NSAS_LEVELS_H
+#define __NSAS_LEVELS_H
+
+/// \brief NSAS Debug Levels
+///
+/// Defines the levels used to output debug messages in the NSAS.  Note that
+/// higher numbers equate to more verbose (and detailed) output.
+
+const int NSAS_DBG_TRACE = 10;  // Trace of normal operations
+
+#endif // __NSAS_LEVELS_H
diff --git a/src/lib/nsas/nsasdef.cc b/src/lib/nsas/nsasdef.cc
new file mode 100644
index 0000000..220ab80
--- /dev/null
+++ b/src/lib/nsas/nsasdef.cc
@@ -0,0 +1,27 @@
+// File created from nsasdef.msg on Thu Apr 28 09:42:02 2011
+
+#include <cstddef>
+#include <log/message_types.h>
+#include <log/message_initializer.h>
+
+namespace isc {
+namespace nsas {
+
+extern const isc::log::MessageID NSAS_LOOKUPCANCEL = "LOOKUPCANCEL";
+extern const isc::log::MessageID NSAS_LOOKUPZONE = "LOOKUPZONE";
+
+} // namespace nsas
+} // namespace isc
+
+namespace {
+
+const char* values[] = {
+    "LOOKUPCANCEL", "lookup for zone %s has been cancelled",
+    "LOOKUPZONE", "searching NSAS for nameservers for zone %s",
+    NULL
+};
+
+const isc::log::MessageInitializer initializer(values);
+
+} // Anonymous namespace
+
diff --git a/src/lib/nsas/nsasdef.h b/src/lib/nsas/nsasdef.h
new file mode 100644
index 0000000..de69436
--- /dev/null
+++ b/src/lib/nsas/nsasdef.h
@@ -0,0 +1,17 @@
+// File created from nsasdef.msg on Thu Apr 28 09:42:02 2011
+
+#ifndef __NSASDEF_H
+#define __NSASDEF_H
+
+#include <log/message_types.h>
+
+namespace isc {
+namespace nsas {
+
+extern const isc::log::MessageID NSAS_LOOKUPCANCEL;
+extern const isc::log::MessageID NSAS_LOOKUPZONE;
+
+} // namespace nsas
+} // namespace isc
+
+#endif // __NSASDEF_H
diff --git a/src/lib/nsas/nsasdef.msg b/src/lib/nsas/nsasdef.msg
new file mode 100644
index 0000000..bfcdd21
--- /dev/null
+++ b/src/lib/nsas/nsasdef.msg
@@ -0,0 +1,24 @@
+# Copyright (C) 2011  Internet Systems Consortium, Inc. ("ISC")
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+# AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+# PERFORMANCE OF THIS SOFTWARE.
+
+$PREFIX NSAS_
+$NAMESPACE isc::nsas
+
+LOOKUPCANCEL    lookup for zone %s has been cancelled
++ A debug message, this is output when a NSAS lookup for a zone has been
++ cancelled.
+
+LOOKUPZONE      searching NSAS for nameservers for zone %s
++ A debug message, this is output when a call is made to the NSAS to obtain
++ the nameservers for the specified zone.
diff --git a/src/lib/nsas/tests/Makefile.am b/src/lib/nsas/tests/Makefile.am
index 56f36d1..e9235ba 100644
--- a/src/lib/nsas/tests/Makefile.am
+++ b/src/lib/nsas/tests/Makefile.am
@@ -53,6 +53,7 @@ endif
 
 run_unittests_LDADD += $(top_builddir)/src/lib/nsas/libnsas.la
 run_unittests_LDADD += $(top_builddir)/src/lib/util/libutil.la
+run_unittests_LDADD += $(top_builddir)/src/lib/log/liblog.la
 run_unittests_LDADD += $(top_builddir)/src/lib/dns/libdns++.la
 run_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libasiolink.la
 run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
diff --git a/src/lib/nsas/tests/run_unittests.cc b/src/lib/nsas/tests/run_unittests.cc
index d1277ad..299c48c 100644
--- a/src/lib/nsas/tests/run_unittests.cc
+++ b/src/lib/nsas/tests/run_unittests.cc
@@ -13,14 +13,78 @@
 // PERFORMANCE OF THIS SOFTWARE.
 
 #include <config.h>
+#include <stdlib.h>
+
+#include <string>
+#include <boost/lexical_cast.hpp>
 
 #include <gtest/gtest.h>
 
 #include <dns/tests/unittest_util.h>
+#include <log/logger_support.h>
+
+using namespace std;
+
+// Initialize the logging.
+void init_logging() {
+
+    const char* DEFAULT_ROOT = "b10root";
+
+    // Root logger name is defined by the environment variable B10_LOGGER_ROOT.
+    // If not present, the name is "b10root".
+    const char* root = getenv("B10_LOGGER_ROOT");
+    if (! root) {
+        root = DEFAULT_ROOT;
+    }
+
+    // Set the logging severity.  The environment variable is
+    // B10_LOGGER_SEVERITY, and can be one of "DEBUG", "INFO", "WARN", "ERROR"
+    // of "FATAL".  Note that the string must be in upper case with no leading
+    // of trailing blanks.
+    isc::log::Severity severity = isc::log::DEFAULT;
+    const char* sev_char = getenv("B10_LOGGER_SEVERITY");
+    if (sev_char) {
+        string sev_string(sev_char);
+        if (sev_string == "DEBUG") {
+            severity = isc::log::DEBUG;
+        } else if (sev_string == "INFO") {
+            severity = isc::log::INFO;
+        } else if (sev_string == "WARN") {
+            severity = isc::log::WARN;
+        } else if (sev_string == "ERROR") {
+            severity = isc::log::ERROR;
+        } else if (sev_string == "FATAL") {
+            severity = isc::log::FATAL;
+        }
+    }
+
+    // If the severity is debug, get the debug level (environment variable
+    // B10_LOGGER_DBGLEVEL), which should be in the range 0 to 99.
+    int dbglevel = 0;
+    if (severity == isc::log::DEBUG) {
+        const char* dbg_char = getenv("B10_LOGGER_DBGLEVEL");
+        if (dbg_char) {
+            int level = 0;
+            try {
+                level = boost::lexical_cast<int>(dbg_char);
+            } catch (...) {
+                // Error, but not fatal to the test
+                std::cerr << "***ERROR*** Unable to translate "
+                             "B10_LOGGER_DBGLEVEL \n";
+            }
+            dbglevel = level;
+        }
+    }
+
+    // Initialize logging
+    isc::log::initLogger(root, severity, dbglevel, NULL);
+}
 
 int
 main(int argc, char* argv[]) {
     ::testing::InitGoogleTest(&argc, argv);
 
+    init_logging();
+
     return (RUN_ALL_TESTS());
 }




More information about the bind10-changes mailing list