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
)
This commit is contained in:
parent
a67f7b5ce5
commit
c77f3c9aa8
@ -82,7 +82,7 @@ class OSJournalHandler(logging.Handler):
|
|||||||
'request_id',
|
'request_id',
|
||||||
)
|
)
|
||||||
|
|
||||||
def __init__(self, facility):
|
def __init__(self, facility=None):
|
||||||
if not journal:
|
if not journal:
|
||||||
raise RuntimeError("Systemd bindings do not exist")
|
raise RuntimeError("Systemd bindings do not exist")
|
||||||
|
|
||||||
|
@ -29,6 +29,10 @@ try:
|
|||||||
import syslog
|
import syslog
|
||||||
except ImportError:
|
except ImportError:
|
||||||
syslog = None
|
syslog = None
|
||||||
|
try:
|
||||||
|
from systemd import journal
|
||||||
|
except ImportError:
|
||||||
|
journal = None
|
||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
@ -390,6 +394,15 @@ class OSJournalHandlerTestCase(BaseTestCase):
|
|||||||
self.addCleanup(self.journal.stop)
|
self.addCleanup(self.journal.stop)
|
||||||
log.setup(self.CONF, 'testing')
|
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):
|
def test_emit(self):
|
||||||
logger = log.getLogger('nova-test.foo')
|
logger = log.getLogger('nova-test.foo')
|
||||||
local_context = _fake_new_context()
|
local_context = _fake_new_context()
|
||||||
|
Loading…
Reference in New Issue
Block a user