BIND 10 trac1024, updated. 71eee6e279d7527adbc1e325b0cca49d824b67ee [trac1024] Make "reset unit test root logger" available to Python
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed Jul 13 17:47:06 UTC 2011
The branch, trac1024 has been updated
via 71eee6e279d7527adbc1e325b0cca49d824b67ee (commit)
via 0958095d36903cd821afc57be0c038896dd1acdb (commit)
from 8e66cc336b29bd5acc1f764f26cb0b116db4dc87 (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 71eee6e279d7527adbc1e325b0cca49d824b67ee
Author: Stephen Morris <stephen at isc.org>
Date: Wed Jul 13 18:46:10 2011 +0100
[trac1024] Make "reset unit test root logger" available to Python
... and use it in the Python unit tests that generate logging output.
commit 0958095d36903cd821afc57be0c038896dd1acdb
Author: Stephen Morris <stephen at isc.org>
Date: Wed Jul 13 18:41:57 2011 +0100
[trac1024] Rename function resetting root logger characteristics
Shortened the name to resetUnitTestRootLogger() to make it a bit less
of a mouthful.
-----------------------------------------------------------------------
Summary of changes:
src/bin/bind10/tests/bind10_test.py.in | 2 +
src/bin/cmdctl/tests/cmdctl_test.py | 2 +
src/bin/xfrout/tests/xfrout_test.py.in | 2 +
src/lib/log/logger_unittest_support.cc | 4 +-
src/lib/log/logger_unittest_support.h | 6 ++--
src/lib/log/tests/logger_level_impl_unittest.cc | 2 +-
src/lib/log/tests/logger_level_unittest.cc | 2 +-
src/lib/log/tests/logger_support_unittest.cc | 2 +-
src/lib/python/isc/log/log.cc | 29 ++++++++++++++++++++++-
9 files changed, 42 insertions(+), 9 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/bind10/tests/bind10_test.py.in b/src/bin/bind10/tests/bind10_test.py.in
index 91d326c..9d794a6 100644
--- a/src/bin/bind10/tests/bind10_test.py.in
+++ b/src/bin/bind10/tests/bind10_test.py.in
@@ -26,6 +26,7 @@ import socket
from isc.net.addr import IPAddr
import time
import isc
+import isc.log
from isc.testutils.parse_args import TestOptParser, OptsError
@@ -764,4 +765,5 @@ class TestBrittle(unittest.TestCase):
self.assertFalse(bob.runnable)
if __name__ == '__main__':
+ isc.log.resetUnitTestRootLogger()
unittest.main()
diff --git a/src/bin/cmdctl/tests/cmdctl_test.py b/src/bin/cmdctl/tests/cmdctl_test.py
index e77c529..3103f47 100644
--- a/src/bin/cmdctl/tests/cmdctl_test.py
+++ b/src/bin/cmdctl/tests/cmdctl_test.py
@@ -19,6 +19,7 @@ import socket
import tempfile
import sys
from cmdctl import *
+import isc.log
SPEC_FILE_PATH = '..' + os.sep
if 'CMDCTL_SPEC_PATH' in os.environ:
@@ -447,6 +448,7 @@ class TestFuncNotInClass(unittest.TestCase):
if __name__== "__main__":
+ isc.log.resetUnitTestRootLogger()
unittest.main()
diff --git a/src/bin/xfrout/tests/xfrout_test.py.in b/src/bin/xfrout/tests/xfrout_test.py.in
index adabf48..7ab4a58 100644
--- a/src/bin/xfrout/tests/xfrout_test.py.in
+++ b/src/bin/xfrout/tests/xfrout_test.py.in
@@ -23,6 +23,7 @@ from isc.cc.session import *
from pydnspp import *
from xfrout import *
import xfrout
+import isc.log
TSIG_KEY = TSIGKey("example.com:SFuWd/q99SzF8Yzd1QbB9g==")
@@ -670,4 +671,5 @@ class TestInitialization(unittest.TestCase):
self.assertEqual(xfrout.UNIX_SOCKET_FILE, "The/Socket/File")
if __name__== "__main__":
+ isc.log.resetUnitTestRootLogger()
unittest.main()
diff --git a/src/lib/log/logger_unittest_support.cc b/src/lib/log/logger_unittest_support.cc
index 86d8491..a0969be 100644
--- a/src/lib/log/logger_unittest_support.cc
+++ b/src/lib/log/logger_unittest_support.cc
@@ -80,7 +80,7 @@ b10LoggerDbglevel(int defdbglevel) {
// variables B10_LOGGER_SEVERITY, B10_LOGGER_DBGLEVEL and B10_LOGGER_DESTINATION.
void
-setUnitTestRootLoggerCharacteristics() {
+resetUnitTestRootLogger() {
using namespace isc::log;
@@ -168,7 +168,7 @@ void initLogger(isc::log::Severity severity, int dbglevel) {
// in the environment variables. (The two-step approach is used as the
// setUnitTestRootLoggerCharacteristics() function is used in several
// places in the BIND 10 tests, and it avoid duplicating code.)
- setUnitTestRootLoggerCharacteristics();
+ resetUnitTestRootLogger();
}
} // namespace log
diff --git a/src/lib/log/logger_unittest_support.h b/src/lib/log/logger_unittest_support.h
index 221566a..e98544e 100644
--- a/src/lib/log/logger_unittest_support.h
+++ b/src/lib/log/logger_unittest_support.h
@@ -103,15 +103,15 @@ isc::log::Severity b10LoggerSeverity(isc::log::Severity defseverity);
int b10LoggerDbglevel(int defdbglevel);
-/// \brief Reset Logger Characteristics
+/// \brief Reset Root Logger Characteristics
///
-/// This is a simplified interface into the setting of the characteristics
+/// This is a simplified interface into the resetting of the characteristics
/// of the root logger. It is aimed for use in unit tests and resets the
/// characteristics of the root logger to use a severity, debug level and
/// destination set by the environment variables B10_LOGGER_SEVERITY,
/// B10_LOGGER_DBGLEVEL and B10_LOGGER_DESTINATION.
void
-setUnitTestRootLoggerCharacteristics();
+resetUnitTestRootLogger();
} // namespace log
} // namespace isc
diff --git a/src/lib/log/tests/logger_level_impl_unittest.cc b/src/lib/log/tests/logger_level_impl_unittest.cc
index 0342328..dacd202 100644
--- a/src/lib/log/tests/logger_level_impl_unittest.cc
+++ b/src/lib/log/tests/logger_level_impl_unittest.cc
@@ -30,7 +30,7 @@ class LoggerLevelImplTest : public ::testing::Test {
protected:
LoggerLevelImplTest() {
// Ensure logging set to default for unit tests
- setUnitTestRootLoggerCharacteristics();
+ resetUnitTestRootLogger();
}
~LoggerLevelImplTest()
diff --git a/src/lib/log/tests/logger_level_unittest.cc b/src/lib/log/tests/logger_level_unittest.cc
index efb5937..641a6cc 100644
--- a/src/lib/log/tests/logger_level_unittest.cc
+++ b/src/lib/log/tests/logger_level_unittest.cc
@@ -31,7 +31,7 @@ protected:
LoggerLevelTest() {
// Logger initialization is done in main(). As logging tests may
// alter the default logging output, it is reset here.
- setUnitTestRootLoggerCharacteristics();
+ resetUnitTestRootLogger();
}
~LoggerLevelTest() {
LoggerManager::reset();
diff --git a/src/lib/log/tests/logger_support_unittest.cc b/src/lib/log/tests/logger_support_unittest.cc
index 1c1bc32..b418906 100644
--- a/src/lib/log/tests/logger_support_unittest.cc
+++ b/src/lib/log/tests/logger_support_unittest.cc
@@ -23,7 +23,7 @@ protected:
LoggerSupportTest() {
// Logger initialization is done in main(). As logging tests may
// alter the default logging output, it is reset here.
- setUnitTestRootLoggerCharacteristics();
+ resetUnitTestRootLogger();
}
~LoggerSupportTest() {
}
diff --git a/src/lib/python/isc/log/log.cc b/src/lib/python/isc/log/log.cc
index 484151f..ace1f71 100644
--- a/src/lib/python/isc/log/log.cc
+++ b/src/lib/python/isc/log/log.cc
@@ -20,6 +20,7 @@
#include <log/message_dictionary.h>
#include <log/logger_manager.h>
+#include <log/logger_support.h>
#include <log/logger.h>
#include <config/ccsession.h>
@@ -35,7 +36,7 @@ using boost::bind;
// (tags/RELEASE_28 115909)) on OSX, where unwinding the stack
// segfaults the moment this exception was thrown and caught.
//
-// Placing it in a named namespace instead of the original
+// Placing it in a named namespace instead of the originalRecommend
// unnamed namespace appears to solve this, so as a temporary
// workaround, we create a local randomly named namespace here
// to solve this issue.
@@ -184,6 +185,27 @@ init(PyObject*, PyObject* args) {
Py_RETURN_NONE;
}
+// This initialization is for unit tests. It allows message settings to be
+// be determined by a set of B10_xxx environment variables. (See the
+// description of initLogger() for more details.) The function has been named
+// resetUnitTestRootLogger() here as being more descriptive and
+// trying to avoid confusion.
+PyObject*
+resetUnitTestRootLogger(PyObject*, PyObject*) {
+ try {
+ isc::log::resetUnitTestRootLogger();
+ }
+ catch (const std::exception& e) {
+ PyErr_SetString(PyExc_RuntimeError, e.what());
+ return (NULL);
+ }
+ catch (...) {
+ PyErr_SetString(PyExc_RuntimeError, "Unknown C++ exception");
+ return (NULL);
+ }
+ Py_RETURN_NONE;
+}
+
PyObject*
logConfigUpdate(PyObject*, PyObject* args) {
// we have no wrappers for ElementPtr and ConfigData,
@@ -246,6 +268,11 @@ PyMethodDef methods[] = {
"logging severity (one of 'DEBUG', 'INFO', 'WARN', 'ERROR' or "
"'FATAL'), a debug level (integer in the range 0-99) and a file name "
"of a dictionary with message text translations."},
+ {"resetUnitTestRootLogger", resetUnitTestRootLogger, METH_VARARGS,
+ "Initialization for unit tests. Sets the severity and output stream "
+ "according to a set of environment variables. This should not be "
+ "used in production code. The name is slightly confusing, but it "
+ "mirrors a method of the same name used for the C++ unit tests."},
{"log_config_update", logConfigUpdate, METH_VARARGS,
"Update logger settings. This method is automatically used when "
"ModuleCCSession is initialized with handle_logging_config set "
More information about the bind10-changes
mailing list