From 84371c2cfda49483f6dabc6bb85cb0131df1053e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sun, 19 Mar 2017 12:59:51 -0400 Subject: journal: rename SENDER_FUNCTION to sender_function Let's not try to make it look like a journal field. It should be a normal parameter. Followup for dce0a855c3281e7051b1cbe0f73386d1c90ef320. --- systemd/journal.py | 7 +++++-- systemd/test/test_journal.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/systemd/journal.py b/systemd/journal.py index 39e87ec..e23e5a5 100644 --- a/systemd/journal.py +++ b/systemd/journal.py @@ -548,9 +548,12 @@ class JournalHandler(_logging.Handler): `THREAD_NAME`, `CODE_FILE`, `CODE_LINE`, `CODE_FUNC`, `LOGGER` (name as supplied to getLogger call), `MESSAGE_ID` (optional, see above), `SYSLOG_IDENTIFIER` (defaults to sys.argv[0]). + + The function used to actually send messages can be overridden using + the `sender_function` parameter. """ - def __init__(self, level=_logging.NOTSET, **kwargs): + def __init__(self, level=_logging.NOTSET, sender_function=send, **kwargs): super(JournalHandler, self).__init__(level) for name in kwargs: @@ -559,7 +562,7 @@ class JournalHandler(_logging.Handler): if 'SYSLOG_IDENTIFIER' not in kwargs: kwargs['SYSLOG_IDENTIFIER'] = _sys.argv[0] - self.send = kwargs.pop('SENDER_FUNCTION', send) + self.send = sender_function self._extra = kwargs def emit(self, record): diff --git a/systemd/test/test_journal.py b/systemd/test/test_journal.py index ce6ba97..93b966e 100644 --- a/systemd/test/test_journal.py +++ b/systemd/test/test_journal.py @@ -90,7 +90,7 @@ def test_journalhandler_info(): record = logging.LogRecord('test-logger', logging.INFO, 'testpath', 1, 'test', None, None) sender = MockSender() - kw = {'X':3, 'X3':4, 'SENDER_FUNCTION': sender.send} + kw = {'X':3, 'X3':4, 'sender_function': sender.send} handler = journal.JournalHandler(logging.INFO, **kw) handler.emit(record) assert len(sender.buf) == 1 -- cgit v1.2.1