[svn] commit: r2337 - in /branches/trac176/src/lib/python/isc/log: log.py tests/log_test.py

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Jun 30 02:08:53 UTC 2010


Author: chenzhengzhang
Date: Wed Jun 30 02:08:53 2010
New Revision: 2337

Log:
Add syslog handler unittest


Modified:
    branches/trac176/src/lib/python/isc/log/log.py
    branches/trac176/src/lib/python/isc/log/tests/log_test.py

Modified: branches/trac176/src/lib/python/isc/log/log.py
==============================================================================
--- branches/trac176/src/lib/python/isc/log/log.py (original)
+++ branches/trac176/src/lib/python/isc/log/log.py Wed Jun 30 02:08:53 2010
@@ -177,13 +177,13 @@
         self._stream_handler.setFormatter(TIME_FORMATTER)
         self.addHandler(self._stream_handler)
 
-    def _add_syslog_handler(self, facility=syslog.LOG_USER):
+    def _add_syslog_handler(self, nsfacility=syslog.LOG_USER):
         """Add a syslog handler.
    
         If facility is not specified, LOG_USER is used.
         The default severity level is INFO.
         """
-        self._syslog_handler = NSSysLogHandler('BIND10', facility)
+        self._syslog_handler = NSSysLogHandler('BIND10', facility = nsfacility)
         self._syslog_handler.setFormatter(FORMATTER)
         #set syslog handler severity level INFO
         self._syslog_handler.setLevel(logging.INFO)

Modified: branches/trac176/src/lib/python/isc/log/tests/log_test.py
==============================================================================
--- branches/trac176/src/lib/python/isc/log/tests/log_test.py (original)
+++ branches/trac176/src/lib/python/isc/log/tests/log_test.py Wed Jun 30 02:08:53 2010
@@ -49,6 +49,18 @@
         self.FILE_LOG1.close()
         self.FILE_LOG2.close()
         self.FILE_LOG3.close()
+
+class TestSysLogHandler(unittest.TestCase):
+    def setUp(self):
+        self.handler = NSSysLogHandler("BIND10")
+
+    def test_encodeLevel(self):
+        sysLevel = self.handler._encodeLevel(logging.ERROR)
+        self.assertEqual(sysLevel, syslog.LOG_ERR)
+
+    def test_emit(self):
+        record = logging.LogRecord(None, None, "", 0, "syslog handler", (), None, None)
+        self.handler.emit(record)
 
 
 class TestLogging(unittest.TestCase):




More information about the bind10-changes mailing list