Commit bfc4bec5 authored by Jerry's avatar Jerry
Browse files

Add syslog handler unittest



git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac176@2337 e5f2f494-b856-4b98-b285-d166d9295462
parent 963591b9
......@@ -177,13 +177,13 @@ class NSLogger(logging.getLoggerClass()):
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)
......
......@@ -50,6 +50,18 @@ class TestRotateFileHandler(unittest.TestCase):
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):
......
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