Browse Source

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
(cherry picked from commit 184235c265)
(cherry picked from commit c77f3c9aa8)
(cherry picked from commit e19c4076b1)
tags/3.42.5^0
Brian Haley 1 month ago
committed by Stephen Finucane
parent
commit
ef23f70850
2 changed files with 14 additions and 1 deletions
  1. +1
    -1
      oslo_log/handlers.py
  2. +13
    -0
      oslo_log/tests/unit/test_log.py

+ 1
- 1
oslo_log/handlers.py View File

@@ -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")



+ 13
- 0
oslo_log/tests/unit/test_log.py View File

@@ -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()


Loading…
Cancel
Save