diff options
Diffstat (limited to 'systemd/journal.py')
-rw-r--r-- | systemd/journal.py | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/systemd/journal.py b/systemd/journal.py index 41ffbdc..83e3004 100644 --- a/systemd/journal.py +++ b/systemd/journal.py @@ -236,7 +236,7 @@ class Reader(_Reader): super(Reader, self).add_match(arg) def get_next(self, skip=1): - """Return the next log entry as a dictionary. + r"""Return the next log entry as a dictionary. Entries will be processed with converters specified during Reader creation. @@ -257,7 +257,7 @@ class Reader(_Reader): return dict() def get_previous(self, skip=1): - """Return the previous log entry. + r"""Return the previous log entry. Equivalent to get_next(-skip). @@ -546,6 +546,8 @@ class JournalHandler(_logging.Handler): raise ValueError('Invalid field name: ' + name) if 'SYSLOG_IDENTIFIER' not in kwargs: kwargs['SYSLOG_IDENTIFIER'] = _sys.argv[0] + + self.send = kwargs.pop('SENDER_FUNCTION', send) self._extra = kwargs def emit(self, record): @@ -559,9 +561,9 @@ class JournalHandler(_logging.Handler): msg = self.format(record) pri = self.mapPriority(record.levelno) mid = getattr(record, 'MESSAGE_ID', None) - extras = { k:str(v) for k,v in self._extra.iteritems() } + extras = { k:str(v) for k,v in self._extra.items() } extras.update({ - k:str(v) for k,v in record.__dict__.iteritems() + k:str(v) for k,v in record.__dict__.items() }) if record.exc_text: @@ -573,16 +575,16 @@ class JournalHandler(_logging.Handler): if record.args: extras['CODE_ARGS'] = str(record.args) - send(msg, - MESSAGE_ID=mid, - PRIORITY=format(pri), - LOGGER=record.name, - THREAD_NAME=record.threadName, - PROCESS_NAME=record.processName, - CODE_FILE=record.pathname, - CODE_LINE=record.lineno, - CODE_FUNC=record.funcName, - **extras) + self.send(msg, + MESSAGE_ID=mid, + PRIORITY=format(pri), + LOGGER=record.name, + THREAD_NAME=record.threadName, + PROCESS_NAME=record.processName, + CODE_FILE=record.pathname, + CODE_LINE=record.lineno, + CODE_FUNC=record.funcName, + **extras) except Exception: self.handleError(record) |