Commit b92cca79 authored by Stephen Morris's avatar Stephen Morris

[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.
parent abdf6245
......@@ -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
......@@ -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) {
......
......@@ -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
......
......@@ -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());
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment