[issue14452] SysLogHandler sends invalid messages when using unicode
marko kreen
report at bugs.python.org
Thu Apr 5 13:55:40 CEST 2012
marko kreen <markokr at gmail.com> added the comment:
The 'msg' in SysLogHandler does not correspond to MSG in RFC.
Nor to %(message)s in log record.
RFC:
------------------------
SYSLOG-MSG = HEADER SP STRUCTURED-DATA [SP MSG]
HEADER = PRI VERSION SP TIMESTAMP SP HOSTNAME
SP APP-NAME SP PROCID SP MSGID
PRI = "<" PRIVAL ">"
[...]
MSG = MSG-ANY / MSG-UTF8
MSG-ANY = *OCTET ; not starting with BOM
MSG-UTF8 = BOM UTF-8-STRING
BOM = %xEF.BB.BF
--------------------------------
logging:
The SysLogHandler does not provide any fields after PRI.
Which is OK, those can be added via format string.
We are using following formatter to get RFC-like structure
to message:
[formatter_syslog]
format=%(hostname)s %(service_name)s %(job_name)s %(message)s
That's not fully compliant, but that's beside the point.
The problem is that SysLogHandler puts BOM before hostname
not before %(message)s. In Python 2.6 it put it even before PRI,
which was even more annoying.
I see 2 solutions to this:
1) Stop putting BOM at all, its not necessary.
2) Put the BOM into %(message)s somehow, thus working with whatever
format is given.
----------
status: pending -> open
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14452>
_______________________________________
More information about the Python-bugs-list
mailing list