diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2010-05-24 09:43:13 (GMT) |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2010-05-24 09:43:13 (GMT) |
commit | cb7ea2912ab5bdb8e6b3fadfb23a510825d36625 (patch) | |
tree | 4828d56c412b002e940cc0dfe2b83e351fb9be89 /Lib/logging | |
parent | c28d554db8278d7346ff28da2defb59d413f857e (diff) | |
download | cpython-cb7ea2912ab5bdb8e6b3fadfb23a510825d36625.zip cpython-cb7ea2912ab5bdb8e6b3fadfb23a510825d36625.tar.gz cpython-cb7ea2912ab5bdb8e6b3fadfb23a510825d36625.tar.bz2 |
Issue #8795: logging: Backported trunk fix for SysLogHandler and Unicode.
Diffstat (limited to 'Lib/logging')
-rw-r--r-- | Lib/logging/handlers.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py index f05d1f6..756baf0 100644 --- a/Lib/logging/handlers.py +++ b/Lib/logging/handlers.py @@ -31,6 +31,11 @@ try: import codecs except ImportError: codecs = None +try: + unicode + _unicode = True +except NameError: + _unicode = False # # Some constants... @@ -777,6 +782,11 @@ class SysLogHandler(logging.Handler): self.encodePriority(self.facility, self.mapPriority(record.levelname)), 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: if self.unixsocket: try: |