diff options
author | Brian Haley <bhaley@redhat.com> | 2020-06-01 17:25:56 -0400 |
---|---|---|
committer | Stephen Finucane <stephenfin@redhat.com> | 2020-06-03 09:57:17 +0000 |
commit | ef23f7085059a7844be308db454a20168fbc97e1 (patch) | |
tree | 1d6d7adaeded6291e4de5665841abffc8a594a18 | |
parent | 19fd9a2e2a283705552cb2c1f53c229b6ecf85e1 (diff) | |
download | oslo-log-stable/stein.tar.gz |
Default facility to None in OSJournalHandler classstein-em3.42.5stable/stein
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
(cherry picked from commit 184235c26517598d6e60f4db72e095ba061a0d6e)
(cherry picked from commit c77f3c9aa82364c482be9b37e6d29634273bb90f)
(cherry picked from commit e19c4076b1f0d7fdbd6d68a09c973934029926a1)
-rw-r--r-- | oslo_log/handlers.py | 2 | ||||
-rw-r--r-- | oslo_log/tests/unit/test_log.py | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/oslo_log/handlers.py b/oslo_log/handlers.py index d4f5fc7..ffd04f9 100644 --- a/oslo_log/handlers.py +++ b/oslo_log/handlers.py @@ -107,7 +107,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 9ff58cf..db3e458 100644 --- a/oslo_log/tests/unit/test_log.py +++ b/oslo_log/tests/unit/test_log.py @@ -28,6 +28,10 @@ try: import syslog except ImportError: syslog = None +try: + from systemd import journal +except ImportError: + journal = None import tempfile import time @@ -395,6 +399,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): l = log.getLogger('nova-test.foo') local_context = _fake_new_context() |