]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #7077: logging: SysLogHandler now treats Unicode as per RFC 5424.
authorVinay Sajip <vinay_sajip@yahoo.co.uk>
Wed, 21 Oct 2009 20:22:14 +0000 (20:22 +0000)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>
Wed, 21 Oct 2009 20:22:14 +0000 (20:22 +0000)
Lib/logging/handlers.py
Misc/NEWS

index 2d71470ceb520dd31690531a23a0e80bdc4a592d..2437c341aff6077a449953f206e1bba00c46caaf 100644 (file)
@@ -779,6 +779,10 @@ class SysLogHandler(logging.Handler):
             self.encodePriority(self.facility,
                                 self.mapPriority(record.levelname)),
                                 msg)
+        #Message is a string. Convert to bytes as required by RFC 5424
+        msg = msg.encode('utf-8')
+        if codecs:
+            msg = codecs.BOM_UTF8 + msg
         try:
             if self.unixsocket:
                 try:
index 8984e6fb035faba714920df5d25345ff4e46409d..96ee2ac611c574dd53303a3b5455e3bdf87c8bc8 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -104,6 +104,8 @@ C-API
 Library
 -------
 
+- Issue #7077: logging: SysLogHandler now treats Unicode as per RFC 5424.
+
 - Issue #7099: Decimal.is_normal now returns True for numbers with exponent
   larger than emax.