diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2009-10-21 20:22:14 (GMT) |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2009-10-21 20:22:14 (GMT) |
commit | 5ac6528b91382e218332d367c98f06a5ed8670ff (patch) | |
tree | 207e6aaed6af893d9e872ea972a3fb6f652c5d0b /Lib/logging | |
parent | cf842ad418fa2b4b820e9f15a69dc5dd04dbd546 (diff) | |
download | cpython-5ac6528b91382e218332d367c98f06a5ed8670ff.zip cpython-5ac6528b91382e218332d367c98f06a5ed8670ff.tar.gz cpython-5ac6528b91382e218332d367c98f06a5ed8670ff.tar.bz2 |
Issue #7077: logging: SysLogHandler now treats Unicode as per RFC 5424.
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 bdf82af..d752063 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... @@ -779,6 +784,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: |