mirror of
https://github.com/python/cpython.git
synced 2025-10-10 00:43:41 +00:00
Issue #8795: logging: Backported trunk fix for SysLogHandler and Unicode.
This commit is contained in:
parent
c28d554db8
commit
cb7ea2912a
1 changed files with 10 additions and 0 deletions
|
@ -31,6 +31,11 @@ try:
|
||||||
import codecs
|
import codecs
|
||||||
except ImportError:
|
except ImportError:
|
||||||
codecs = None
|
codecs = None
|
||||||
|
try:
|
||||||
|
unicode
|
||||||
|
_unicode = True
|
||||||
|
except NameError:
|
||||||
|
_unicode = False
|
||||||
|
|
||||||
#
|
#
|
||||||
# Some constants...
|
# Some constants...
|
||||||
|
@ -777,6 +782,11 @@ class SysLogHandler(logging.Handler):
|
||||||
self.encodePriority(self.facility,
|
self.encodePriority(self.facility,
|
||||||
self.mapPriority(record.levelname)),
|
self.mapPriority(record.levelname)),
|
||||||
msg)
|
msg)
|
||||||
|
# Treat unicode messages as required by RFC 5424
|
||||||
|
if _unicode and type(msg) is unicode:
|
||||||
|
msg = msg.encode('utf-8')
|
||||||
|
if codecs:
|
||||||
|
msg = codecs.BOM_UTF8 + msg
|
||||||
try:
|
try:
|
||||||
if self.unixsocket:
|
if self.unixsocket:
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue