summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Haley <bhaley@redhat.com>2020-06-01 17:25:56 -0400
committerBrian Haley <bhaley@redhat.com>2020-06-01 17:58:33 -0400
commit184235c26517598d6e60f4db72e095ba061a0d6e (patch)
tree235e4a72c645fa1cd87af88e0e6a49882d317ffe
parentd0be4dcb937c266e7946281e9b6473a7180d9941 (diff)
downloadoslo-log-184235c26517598d6e60f4db72e095ba061a0d6e.tar.gz
Default facility to None in OSJournalHandler class
Use a default value of None for facility in OSJournalHandler class, as is done in the OSSysLogHandler class. Neutron started failing with a: E1120: No value for argument 'facility' in constructor call With a recent release of oslo.log. Change-Id: I5269b82d219fd2377535120d9d266238d50431b3 Related-Bug: #1871840
-rw-r--r--oslo_log/handlers.py2
-rw-r--r--oslo_log/tests/unit/test_log.py13
2 files changed, 14 insertions, 1 deletions
diff --git a/oslo_log/handlers.py b/oslo_log/handlers.py
index 1ed4e0c..4f4f054 100644
--- a/oslo_log/handlers.py
+++ b/oslo_log/handlers.py
@@ -82,7 +82,7 @@ class OSJournalHandler(logging.Handler):
'request_id',
)
- def __init__(self, facility):
+ def __init__(self, facility=None):
if not journal:
raise RuntimeError("Systemd bindings do not exist")
diff --git a/oslo_log/tests/unit/test_log.py b/oslo_log/tests/unit/test_log.py
index 40c0916..239fb1f 100644
--- a/oslo_log/tests/unit/test_log.py
+++ b/oslo_log/tests/unit/test_log.py
@@ -29,6 +29,10 @@ try:
import syslog
except ImportError:
syslog = None
+try:
+ from systemd import journal
+except ImportError:
+ journal = None
import tempfile
import time
from unittest import mock
@@ -390,6 +394,15 @@ class OSJournalHandlerTestCase(BaseTestCase):
self.addCleanup(self.journal.stop)
log.setup(self.CONF, 'testing')
+ @testtools.skipUnless(journal, "systemd journal binding is not available")
+ def test_handler(self):
+ handler = handlers.OSJournalHandler()
+ handler.emit(
+ logging.LogRecord("foo", logging.INFO,
+ "path", 123, "hey!",
+ None, None))
+ self.assertTrue(self.journal.send.called)
+
def test_emit(self):
logger = log.getLogger('nova-test.foo')
local_context = _fake_new_context()