On 22/04/13 21:31, Zbigniew Jędrzejewski-Szmek wrote:
Otherwise, we get SYSLOG_IDENTIFIER=python or something
similar, which is completely useless.
---
Thoughts?
Specifically, I'm not sure if is worthwhile to allow overriding
SYSLOG_IDENTIFIER per message. Maybe this ability should be removed.
Zbyszek
src/python-systemd/journal.py | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/python-systemd/journal.py b/src/python-systemd/journal.py
index 6c740b0..39db4bb 100644
--- a/src/python-systemd/journal.py
+++ b/src/python-systemd/journal.py
@@ -469,9 +469,15 @@ class JournalHandler(_logging.Handler):
The following journal fields will be sent:
`MESSAGE`, `PRIORITY`, `THREAD_NAME`, `CODE_FILE`, `CODE_LINE`,
`CODE_FUNC`, `LOGGER` (name as supplied to getLogger call),
- `MESSAGE_ID` (optional, see above).
+ `MESSAGE_ID` (optional, see above), `SYSLOG_IDENTIFIER` (optional).
"""
+ def __init__(self, level=_logging.NOTSET, SYSLOG_IDENTIFIER=None):
+ super(JournalHandler, self).__init__(level)
+ self._SYSLOG_IDENTIFIER = (_sys.argv[0]
+ if SYSLOG_IDENTIFIER is None
+ else SYSLOG_IDENTIFIER)
+
def emit(self, record):
"""Write record as journal event.
@@ -485,8 +491,11 @@ class JournalHandler(_logging.Handler):
msg = self.format(record)
pri = self.mapPriority(record.levelno)
mid = getattr(record, 'MESSAGE_ID', None)
+ sid = getattr(record, 'SYSLOG_IDENTIFIER',
+ self._SYSLOG_IDENTIFIER)
send(msg,
MESSAGE_ID=mid,
+ SYSLOG_IDENTIFIER=sid,
PRIORITY=format(pri),
LOGGER=record.name,
THREAD_NAME=record.threadName,
How about having the value as `__name__`, but`_sys.argv[0]` if `__name__
== "__main__`?
--
Steven Hiscocks
_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel