BIND 10 master, updated. e13d28918a391060d9c1f286d19308cb10975cd9 Merge branch 'master' into trac1074
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Oct 27 14:53:58 UTC 2011
The branch, master has been updated
via e13d28918a391060d9c1f286d19308cb10975cd9 (commit)
via ca1d0935b9d65aa1f26dbe4f0cfc0c4db7701900 (commit)
via 2a08eafed9264b790ada134bdee7ee02c995c50e (commit)
via 2d84595398e0a29bd042b848e986e8aa7bc40f75 (commit)
via 621c92d9a19379bb43e98c821183be1aa4d97c7b (commit)
from 5b7e0424c3d826d5c7a9a247d63c7d716b08e470 (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 e13d28918a391060d9c1f286d19308cb10975cd9
Merge: ca1d0935b9d65aa1f26dbe4f0cfc0c4db7701900 5b7e0424c3d826d5c7a9a247d63c7d716b08e470
Author: Stephen Morris <stephen at isc.org>
Date: Thu Oct 27 15:14:51 2011 +0100
Merge branch 'master' into trac1074
commit ca1d0935b9d65aa1f26dbe4f0cfc0c4db7701900
Author: Jelte Jansen <jelte at isc.org>
Date: Tue Oct 18 11:36:31 2011 +0200
[1074] some whitespace corrections
commit 2a08eafed9264b790ada134bdee7ee02c995c50e
Author: Stephen Morris <stephen at isc.org>
Date: Mon Oct 17 14:58:52 2011 +0100
[1074] Add some documentation to the README file
commit 2d84595398e0a29bd042b848e986e8aa7bc40f75
Author: Stephen Morris <stephen at isc.org>
Date: Mon Oct 17 14:22:41 2011 +0100
[1074] Set defined debug levels for the Python code
commit 621c92d9a19379bb43e98c821183be1aa4d97c7b
Author: Stephen Morris <stephen at isc.org>
Date: Fri Oct 14 18:51:48 2011 +0100
[1074] First pass at sorting out C++ devug levels
-----------------------------------------------------------------------
Summary of changes:
src/bin/auth/auth_log.h | 8 +-
src/bin/bind10/bind10_src.py.in | 4 +-
src/bin/cmdctl/cmdctl.py.in | 11 +---
src/bin/resolver/resolver_log.h | 12 ++--
src/bin/stats/stats.py.in | 5 +-
src/bin/stats/stats_httpd.py.in | 7 +-
src/bin/xfrin/xfrin.py.in | 4 +-
src/bin/zonemgr/zonemgr.py.in | 8 +-
src/lib/asiodns/io_fetch.cc | 12 +---
src/lib/cache/logger.h | 17 +++---
src/lib/cc/logger.h | 23 ++++----
src/lib/config/config_log.h | 11 +---
src/lib/datasrc/logger.h | 16 +++---
src/lib/log/Makefile.am | 3 +-
src/lib/log/README | 5 ++
src/lib/log/log_dbglevels.h | 93 ++++++++++++++++++++++++++++++
src/lib/log/macros.h | 1 +
src/lib/nsas/nsas_log.h | 6 +-
src/lib/python/isc/log/log.cc | 37 ++++++++++++-
src/lib/python/isc/log/tests/log_test.py | 10 +++
src/lib/resolve/resolve_log.h | 8 +-
src/lib/server_common/logger.h | 11 ++--
22 files changed, 219 insertions(+), 93 deletions(-)
create mode 100644 src/lib/log/log_dbglevels.h
-----------------------------------------------------------------------
diff --git a/src/bin/auth/auth_log.h b/src/bin/auth/auth_log.h
index 5205624..e0cae0f 100644
--- a/src/bin/auth/auth_log.h
+++ b/src/bin/auth/auth_log.h
@@ -28,19 +28,19 @@ namespace auth {
/// output.
// Debug messages indicating normal startup are logged at this debug level.
-const int DBG_AUTH_START = 10;
+const int DBG_AUTH_START = DBGLVL_START_SHUT;
// Debug level used to log setting information (such as configuration changes).
-const int DBG_AUTH_OPS = 30;
+const int DBG_AUTH_OPS = DBGLVL_COMMAND;
// Trace detailed operations, including errors raised when processing invalid
// packets. (These are not logged at severities of WARN or higher for fear
// that a set of deliberately invalid packets set to the authoritative server
// could overwhelm the logging.)
-const int DBG_AUTH_DETAIL = 50;
+const int DBG_AUTH_DETAIL = DBGLVL_TRACE_BASIC;
// This level is used to log the contents of packets received and sent.
-const int DBG_AUTH_MESSAGES = 70;
+const int DBG_AUTH_MESSAGES = DBGLVL_TRACE_DETAIL_DATA;
/// Define the logger for the "auth" module part of b10-auth. We could define
/// a logger in each file, but we would want to define a common name to avoid
diff --git a/src/bin/bind10/bind10_src.py.in b/src/bin/bind10/bind10_src.py.in
index b0cd3a6..22309d6 100755
--- a/src/bin/bind10/bind10_src.py.in
+++ b/src/bin/bind10/bind10_src.py.in
@@ -77,8 +77,8 @@ logger = isc.log.Logger("boss")
# Pending system-wide debug level definitions, the ones we
# use here are hardcoded for now
-DBG_PROCESS = 10
-DBG_COMMANDS = 30
+DBG_PROCESS = logger.DBGLVL_TRACE_BASIC
+DBG_COMMANDS = logger.DBGLVL_TRACE_DETAIL
# Assign this process some longer name
isc.util.process.rename(sys.argv[0])
diff --git a/src/bin/cmdctl/cmdctl.py.in b/src/bin/cmdctl/cmdctl.py.in
index fcd69b8..a791aa3 100755
--- a/src/bin/cmdctl/cmdctl.py.in
+++ b/src/bin/cmdctl/cmdctl.py.in
@@ -49,17 +49,12 @@ from hashlib import sha1
from isc.util import socketserver_mixin
from isc.log_messages.cmdctl_messages import *
-# TODO: these debug-levels are hard-coded here; we are planning on
-# creating a general set of debug levels, see ticket #1074. When done,
-# we should remove these values and use the general ones in the
-# logger.debug calls
-
-# Debug level for communication with BIND10
-DBG_CMDCTL_MESSAGING = 30
-
isc.log.init("b10-cmdctl")
logger = isc.log.Logger("cmdctl")
+# Debug level for communication with BIND10
+DBG_CMDCTL_MESSAGING = logger.DBGLVL_COMMAND
+
try:
import threading
except ImportError:
diff --git a/src/bin/resolver/resolver_log.h b/src/bin/resolver/resolver_log.h
index 8378b98..e0e3fda 100644
--- a/src/bin/resolver/resolver_log.h
+++ b/src/bin/resolver/resolver_log.h
@@ -23,20 +23,20 @@
/// Defines the levels used to output debug messages in the resolver. Note that
/// higher numbers equate to more verbose (and detailed) output.
-// Initialization
-const int RESOLVER_DBG_INIT = 10;
+// Initialization and shutdown of the resolver.
+const int RESOLVER_DBG_INIT = DBGLVL_START_SHUT;
// Configuration messages
-const int RESOLVER_DBG_CONFIG = 30;
+const int RESOLVER_DBG_CONFIG = DBGLVL_COMMAND;
// Trace sending and receiving of messages
-const int RESOLVER_DBG_IO = 50;
+const int RESOLVER_DBG_IO = DBGLVL_TRACE_BASIC;
// Trace processing of messages
-const int RESOLVER_DBG_PROCESS = 70;
+const int RESOLVER_DBG_PROCESS = DBGLVL_TRACE_DETAIL;
// Detailed message information
-const int RESOLVER_DBG_DETAIL = 90;
+const int RESOLVER_DBG_DETAIL = DBGLVL_TRACE_DETAIL_DATA;
/// \brief Resolver Logger
diff --git a/src/bin/stats/stats.py.in b/src/bin/stats/stats.py.in
index da00818..3a7f47a 100755
--- a/src/bin/stats/stats.py.in
+++ b/src/bin/stats/stats.py.in
@@ -32,9 +32,8 @@ from isc.log_messages.stats_messages import *
isc.log.init("b10-stats")
logger = isc.log.Logger("stats")
-# Some constants for debug levels, these should be removed when we
-# have #1074
-DBG_STATS_MESSAGING = 30
+# Some constants for debug levels.
+DBG_STATS_MESSAGING = logger.DBGLVL_COMMAND
# This is for boot_time of Stats
_BASETIME = gmtime()
diff --git a/src/bin/stats/stats_httpd.py.in b/src/bin/stats/stats_httpd.py.in
index 596870a..042630d 100644
--- a/src/bin/stats/stats_httpd.py.in
+++ b/src/bin/stats/stats_httpd.py.in
@@ -40,10 +40,9 @@ from isc.log_messages.stats_httpd_messages import *
isc.log.init("b10-stats-httpd")
logger = isc.log.Logger("stats-httpd")
-# Some constants for debug levels, these should be removed when we
-# have #1074
-DBG_STATHTTPD_INIT = 10
-DBG_STATHTTPD_MESSAGING = 30
+# Some constants for debug levels.
+DBG_STATHTTPD_INIT = logger.DBGLVL_START_SHUT
+DBG_STATHTTPD_MESSAGING = logger.DBGLVL_COMMAND
# If B10_FROM_SOURCE is set in the environment, we use data files
# from a directory relative to that, otherwise we use the ones
diff --git a/src/bin/xfrin/xfrin.py.in b/src/bin/xfrin/xfrin.py.in
index 1f5d9a1..91cd918 100755
--- a/src/bin/xfrin/xfrin.py.in
+++ b/src/bin/xfrin/xfrin.py.in
@@ -64,8 +64,8 @@ ZONE_MANAGER_MODULE_NAME = 'Zonemgr'
REFRESH_FROM_ZONEMGR = 'refresh_from_zonemgr'
ZONE_XFRIN_FAILED = 'zone_xfrin_failed'
-# Constants for debug levels, to be removed when we have #1074.
-DBG_XFRIN_TRACE = 3
+# Constants for debug levels.
+DBG_XFRIN_TRACE = logger.DBGLVL_TRACE_BASIC
# These two default are currently hard-coded. For config this isn't
# necessary, but we need these defaults for optional command arguments
diff --git a/src/bin/zonemgr/zonemgr.py.in b/src/bin/zonemgr/zonemgr.py.in
index 5c8d9b5..5bdb765 100755
--- a/src/bin/zonemgr/zonemgr.py.in
+++ b/src/bin/zonemgr/zonemgr.py.in
@@ -43,10 +43,10 @@ from isc.log_messages.zonemgr_messages import *
isc.log.init("b10-zonemgr")
logger = isc.log.Logger("zonemgr")
-# Constants for debug levels, to be removed when we have #1074.
-DBG_START_SHUT = 0
-DBG_ZONEMGR_COMMAND = 10
-DBG_ZONEMGR_BASIC = 40
+# Constants for debug levels.
+DBG_START_SHUT = logger.DBGLVL_START_SHUT
+DBG_ZONEMGR_COMMAND = logger.DBGLVL_COMMAND
+DBG_ZONEMGR_BASIC = logger.DBGLVL_TRACE_BASIC
isc.util.process.rename()
diff --git a/src/lib/asiodns/io_fetch.cc b/src/lib/asiodns/io_fetch.cc
index 31b5f50..466be3e 100644
--- a/src/lib/asiodns/io_fetch.cc
+++ b/src/lib/asiodns/io_fetch.cc
@@ -61,17 +61,13 @@ namespace asiodns {
/// Use the ASIO logger
-namespace {
-
isc::log::Logger logger("asiolink");
+
// Log debug verbosity
-enum {
- DBG_IMPORTANT = 1,
- DBG_COMMON = 20,
- DBG_ALL = 50
-};
-}
+const int DBG_IMPORTANT = DBGLVL_TRACE_BASIC;
+const int DBG_COMMON = DBGLVL_TRACE_DETAIL;
+const int DBG_ALL = DBGLVL_TRACE_DETAIL + 20;
/// \brief IOFetch Data
///
diff --git a/src/lib/cache/logger.h b/src/lib/cache/logger.h
index 8159ed4..3bba413 100644
--- a/src/lib/cache/logger.h
+++ b/src/lib/cache/logger.h
@@ -31,14 +31,13 @@ namespace cache {
/// \brief The logger for this library
extern isc::log::Logger logger;
-enum {
- /// \brief Trace basic operations
- DBG_TRACE_BASIC = 10,
- /// \brief Trace data operations
- DBG_TRACE_DATA = 40,
-};
-
-}
-}
+/// \brief Trace basic operations
+const int DBG_TRACE_BASIC = DBGLVL_TRACE_BASIC;
+
+/// \brief Trace data operations
+const int DBG_TRACE_DATA = DBGLVL_TRACE_BASIC_DATA;
+
+} // namespace cache
+} // namespace isc
#endif
diff --git a/src/lib/cc/logger.h b/src/lib/cc/logger.h
index 567ccee..34b5809 100644
--- a/src/lib/cc/logger.h
+++ b/src/lib/cc/logger.h
@@ -28,20 +28,19 @@
namespace isc {
namespace cc {
-enum {
- /// \brief Trace basic operation
- DBG_TRACE_BASIC = 10,
- /// \brief Trace even details
- ///
- /// This includes messages being sent and received, waiting for messages
- /// and alike.
- DBG_TRACE_DETAILED = 80
-};
+/// Trace basic operation
+const int DBG_TRACE_BASIC = DBGLVL_TRACE_BASIC;
-/// \brief Logger for this library
+/// This includes messages being sent and received, waiting for messages
+/// and alike.
+const int DBG_TRACE_DETAILED = DBGLVL_TRACE_DETAIL;
+
+// Declaration of the logger.
extern isc::log::Logger logger;
-}
-}
+} // namespace cc
+} // namespace isc
+
+/// \brief Logger for this library
#endif
diff --git a/src/lib/config/config_log.h b/src/lib/config/config_log.h
index 74e6a84..21709fd 100644
--- a/src/lib/config/config_log.h
+++ b/src/lib/config/config_log.h
@@ -30,15 +30,10 @@ namespace config {
/// Define the logger used to log messages. We could define it in multiple
/// modules, but defining in a single module and linking to it saves time and
/// space.
-extern isc::log::Logger config_logger; // isc::config::config_logger is the CONFIG logger
+extern isc::log::Logger config_logger;
-/// \brief Debug Levels
-///
-/// Debug levels used in the configuration library
-enum {
- DBG_CONFIG_PROCESS = 40 // Enumerate configuration elements as they
- // ... are processed.
-};
+// Enumerate configuration elements as they are processed.
+const int DBG_CONFIG_PROCESS = DBGLVL_TRACE_BASIC;
} // namespace config
} // namespace isc
diff --git a/src/lib/datasrc/logger.h b/src/lib/datasrc/logger.h
index ac5d50b..c360900 100644
--- a/src/lib/datasrc/logger.h
+++ b/src/lib/datasrc/logger.h
@@ -31,14 +31,14 @@ namespace datasrc {
/// \brief The logger for this library
extern isc::log::Logger logger;
-enum {
- /// \brief Trace basic operations
- DBG_TRACE_BASIC = 10,
- /// \brief Trace data changes and lookups as well
- DBG_TRACE_DATA = 20,
- /// \brief Detailed even about how the lookups happen
- DBG_TRACE_DETAILED = 50
-};
+/// \brief Trace basic operations
+const int DBG_TRACE_BASIC = DBGLVL_TRACE_BASIC;
+
+/// \brief Trace data changes and lookups as well
+const int DBG_TRACE_DATA = DBGLVL_TRACE_BASIC_DATA;
+
+/// \brief Detailed even about how the lookups happen
+const int DBG_TRACE_DETAILED = DBGLVL_TRACE_DETAIL;
}
}
diff --git a/src/lib/log/Makefile.am b/src/lib/log/Makefile.am
index 9f52724..957d350 100644
--- a/src/lib/log/Makefile.am
+++ b/src/lib/log/Makefile.am
@@ -9,6 +9,7 @@ lib_LTLIBRARIES = liblog.la
liblog_la_SOURCES =
liblog_la_SOURCES += dummylog.h dummylog.cc
liblog_la_SOURCES += logimpl_messages.cc logimpl_messages.h
+liblog_la_SOURCES += log_dbglevels.h
liblog_la_SOURCES += log_formatter.h log_formatter.cc
liblog_la_SOURCES += logger.cc logger.h
liblog_la_SOURCES += logger_impl.cc logger_impl.h
@@ -21,8 +22,8 @@ liblog_la_SOURCES += logger_name.cc logger_name.h
liblog_la_SOURCES += logger_specification.h
liblog_la_SOURCES += logger_support.cc logger_support.h
liblog_la_SOURCES += logger_unittest_support.cc logger_unittest_support.h
-liblog_la_SOURCES += macros.h
liblog_la_SOURCES += log_messages.cc log_messages.h
+liblog_la_SOURCES += macros.h
liblog_la_SOURCES += message_dictionary.cc message_dictionary.h
liblog_la_SOURCES += message_exception.h
liblog_la_SOURCES += message_initializer.cc message_initializer.h
diff --git a/src/lib/log/README b/src/lib/log/README
index 3747cb1..3693abb 100644
--- a/src/lib/log/README
+++ b/src/lib/log/README
@@ -477,6 +477,11 @@ the severity system:
When a particular severity is set, it - and all severities and/or debug
levels above it - will be logged.
+To try to ensure that the information from different modules is roughly
+comparable for the same debug level, a set of standard debug levels has
+been defined for common type of debug output. However, modules are free
+to set their own debug levels or define additional ones.
+
Logging Sources v Logging Severities
------------------------------------
When logging events, make a distinction between events related to the
diff --git a/src/lib/log/log_dbglevels.h b/src/lib/log/log_dbglevels.h
new file mode 100644
index 0000000..d713714
--- /dev/null
+++ b/src/lib/log/log_dbglevels.h
@@ -0,0 +1,93 @@
+// 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 __LOG_DBGLVLS_H
+#define __LOG_DBGLVLS_H
+
+/// \file
+///
+/// When a message is logged with DEBUG severity, the debug level associated
+/// with the message is also specified. This debug level is a number
+/// ranging from 0 to 99; the idea is that the higher the debug level, the
+/// more detailed the message.
+///
+/// If debug messages are being logged, the logging system allows them to be
+/// filtered by debug level - only messages logged with a level equal to or
+/// less than the set debug level will be output. (For example, if the
+/// filter is set to 30, only debug messages logged with levels in the range
+/// 0 to 30 will be output; messages logged with levels 31 to 99 will be
+/// suppressed.)
+///
+/// Levels of 30 or below are reserved for debug messages that are most
+/// likely to be useful for an administrator. Levels 31 to 99 are for use by
+/// someone familiar with the code. "Useful for an administrator" is,
+/// admittedly, a subjective term: it is loosely defined as messages helping
+/// someone diagnose a problem that they could solve without needing to dive
+/// into the code. So it covers things like start-up steps and configuration
+/// messages.
+///
+/// In practice, this means that levels of 30 and below are most-likely to
+/// be used by the top-level programs, and 31 and above by the various
+/// libraries.
+///
+/// This file defines a set of standard debug levels for use across all loggers.
+/// In this way users can have some expection of what will be output when
+/// enabling debugging. Symbols are prefixed DBGLVL so as not to clash with
+/// DBG_ symbols in the various modules.
+///
+/// \note If the names of debug constants are changed, or if ones are added or
+/// removed, edit the file src/lib/python/isc/log/log.cc to update the log
+/// level definitions available to Python. The change does not need to be
+/// made if only the numeric values of constants are updated.
+
+namespace {
+
+/// Process startup/shutdown debug messages. Note that these are _debug_
+/// messages, as other messages related to startup and shutdown may be output
+/// with another severity. For example, when the authoritative server starts
+/// up, the "server started" message could be output at a severity of INFO.
+/// "Server starting" and messages indicating the stages in startup should be
+/// debug messages output at this severity.
+///
+/// This is given a value of 0 as that is the level selected if debugging is
+/// enabled without giving a level.
+const int DBGLVL_START_SHUT = 0;
+
+/// This debug level is reserved for logging the exchange of messages/commands
+/// between processes, including configuration messages.
+const int DBGLVL_COMMAND = 10;
+
+/// If the commands have associated data, this level is when they are printed.
+/// This includes configuration messages.
+const int DBGLVL_COMMAND_DATA = 20;
+
+// The following constants are suggested values for common operations.
+// Depending on the exact nature of the code, modules may or may not use these
+// levels.
+
+/// Trace basic operations.
+const int DBGLVL_TRACE_BASIC = 40;
+
+/// Trace data associated with the basic operations.
+const int DBGLVL_TRACE_BASIC_DATA = 45;
+
+/// Trace detailed operations.
+const int DBGLVL_TRACE_DETAIL = 50;
+
+/// Trace data associated with detailed operations.
+const int DBGLVL_TRACE_DETAIL_DATA = 55;
+
+} // Anonymous namespace
+
+#endif // __LOG_DBGLVLS_H
diff --git a/src/lib/log/macros.h b/src/lib/log/macros.h
index 3128131..42fb42e 100644
--- a/src/lib/log/macros.h
+++ b/src/lib/log/macros.h
@@ -16,6 +16,7 @@
#define __LOG_MACROS_H
#include <log/logger.h>
+#include <log/log_dbglevels.h>
/// \brief Macro to conveniently test debug output and log it
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE) \
diff --git a/src/lib/nsas/nsas_log.h b/src/lib/nsas/nsas_log.h
index ec6844f..031f46d 100644
--- a/src/lib/nsas/nsas_log.h
+++ b/src/lib/nsas/nsas_log.h
@@ -29,15 +29,15 @@ namespace nsas {
// The first level traces normal operations - asking the NSAS for an address,
// and cancelling a lookup. It also records when the NSAS calls back to the
// resolver to resolve something.
-const int NSAS_DBG_TRACE = 10;
+const int NSAS_DBG_TRACE = DBGLVL_TRACE_BASIC;
// The next level extends the normal operations and records the results of the
// lookups.
-const int NSAS_DBG_RESULTS = 20;
+const int NSAS_DBG_RESULTS = DBGLVL_TRACE_BASIC_DATA;
// Additional information on the usage of the names - the RTT values obtained
// when queries were done.
-const int NSAS_DBG_RTT = 30;
+const int NSAS_DBG_RTT = DBGLVL_TRACE_DETAIL_DATA;
/// \brief NSAS Logger
diff --git a/src/lib/python/isc/log/log.cc b/src/lib/python/isc/log/log.cc
index 5bb6a94..c7112b3 100644
--- a/src/lib/python/isc/log/log.cc
+++ b/src/lib/python/isc/log/log.cc
@@ -28,7 +28,11 @@
#include <string>
#include <boost/bind.hpp>
+#include <util/python/pycppwrapper_util.h>
+#include <log/log_dbglevels.h>
+
using namespace isc::log;
+using namespace isc::util::python;
using std::string;
using boost::bind;
@@ -723,7 +727,38 @@ PyInit_log(void) {
&logger_type))) < 0) {
return (NULL);
}
- Py_INCREF(&logger_type);
+ // Add in the definitions of the standard debug levels. These can then
+ // be referred to in Python through the constants log.DBGLVL_XXX.
+ // N.B. These should be kept in sync with the constants defined in
+ // log_dbglevels.h.
+ try {
+ installClassVariable(logger_type, "DBGLVL_START_SHUT",
+ Py_BuildValue("I", DBGLVL_START_SHUT));
+ installClassVariable(logger_type, "DBGLVL_COMMAND",
+ Py_BuildValue("I", DBGLVL_COMMAND));
+ installClassVariable(logger_type, "DBGLVL_COMMAND_DATA",
+ Py_BuildValue("I", DBGLVL_COMMAND_DATA));
+ installClassVariable(logger_type, "DBGLVL_TRACE_BASIC",
+ Py_BuildValue("I", DBGLVL_TRACE_BASIC));
+ installClassVariable(logger_type, "DBGLVL_TRACE_BASIC_DATA",
+ Py_BuildValue("I", DBGLVL_TRACE_BASIC_DATA));
+ installClassVariable(logger_type, "DBGLVL_TRACE_DETAIL",
+ Py_BuildValue("I", DBGLVL_TRACE_DETAIL));
+ installClassVariable(logger_type, "DBGLVL_TRACE_DETAIL_DATA",
+ Py_BuildValue("I", DBGLVL_TRACE_DETAIL_DATA));
+ } catch (const std::exception& ex) {
+ const std::string ex_what =
+ "Unexpected failure in Log initialization: " +
+ std::string(ex.what());
+ PyErr_SetString(PyExc_SystemError, ex_what.c_str());
+ return (NULL);
+ } catch (...) {
+ PyErr_SetString(PyExc_SystemError,
+ "Unexpected failure in Log initialization");
+ return (NULL);
+ }
+
+ Py_INCREF(&logger_type);
return (mod);
}
diff --git a/src/lib/python/isc/log/tests/log_test.py b/src/lib/python/isc/log/tests/log_test.py
index 4292b6c..8deaeae 100644
--- a/src/lib/python/isc/log/tests/log_test.py
+++ b/src/lib/python/isc/log/tests/log_test.py
@@ -159,5 +159,15 @@ class Logger(unittest.TestCase):
# Bad type
self.assertRaises(TypeError, logger.debug, "42", "hello")
+ def test_dbglevel_constants(self):
+ """
+ Just check a constant to make sure it is defined and is the
+ correct value. (The constant chosen has a non-zero value to
+ ensure that the code has both define the constant and set its
+ value correctly.)
+ """
+ logger = isc.log.Logger("child")
+ self.assertEqual(logger.DBGLVL_COMMAND, 10)
+
if __name__ == '__main__':
unittest.main()
diff --git a/src/lib/resolve/resolve_log.h b/src/lib/resolve/resolve_log.h
index 1f2869e..828b9d3 100644
--- a/src/lib/resolve/resolve_log.h
+++ b/src/lib/resolve/resolve_log.h
@@ -27,17 +27,17 @@ namespace resolve {
/// Note that higher numbers equate to more verbose (and detailed) output.
// The first level traces normal operations
-const int RESLIB_DBG_TRACE = 10;
+const int RESLIB_DBG_TRACE = DBGLVL_TRACE_BASIC;
// The next level extends the normal operations and records the results of the
// lookups.
-const int RESLIB_DBG_RESULTS = 20;
+const int RESLIB_DBG_RESULTS = DBGLVL_TRACE_BASIC_DATA;
// Report cache lookups and results
-const int RESLIB_DBG_CACHE = 40;
+const int RESLIB_DBG_CACHE = DBGLVL_TRACE_DETAIL_DATA;
// Indicate when callbacks are called
-const int RESLIB_DBG_CB = 50;
+const int RESLIB_DBG_CB = DBGLVL_TRACE_DETAIL_DATA + 10;
/// \brief Resolver Library Logger
diff --git a/src/lib/server_common/logger.h b/src/lib/server_common/logger.h
index cfca1f3..ae07865 100644
--- a/src/lib/server_common/logger.h
+++ b/src/lib/server_common/logger.h
@@ -31,12 +31,11 @@ namespace server_common {
/// \brief The logger for this library
extern isc::log::Logger logger;
-enum {
- /// \brief Trace basic operations
- DBG_TRACE_BASIC = 10,
- /// \brief Print also values used
- DBG_TRACE_VALUES = 40
-};
+/// \brief Trace basic operations
+const int DBG_TRACE_BASIC = DBGLVL_TRACE_BASIC;
+
+/// \brief Print also values used
+const int DBG_TRACE_VALUES = DBGLVL_TRACE_BASIC_DATA;
}
}
More information about the bind10-changes
mailing list