summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2010-08-19 22:20:22 (GMT)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2010-08-19 22:20:22 (GMT)
commit467d12fcb2987d6530e683709978d6aadd7ceb05 (patch)
tree3296ab7033a2152f84fda13df3177a1cc91d1f38
parent12844e6df6d6ae2a8b51e6440b8b15b10a78949a (diff)
downloadcpython-467d12fcb2987d6530e683709978d6aadd7ceb05.zip
cpython-467d12fcb2987d6530e683709978d6aadd7ceb05.tar.gz
cpython-467d12fcb2987d6530e683709978d6aadd7ceb05.tar.bz2
Issue #7077: Fixed SysLogHandler implementation of Unicode handling.
-rw-r--r--Lib/logging/handlers.py14
1 files changed, 4 insertions, 10 deletions
diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py
index 61dbf31..dc2d973 100644
--- a/Lib/logging/handlers.py
+++ b/Lib/logging/handlers.py
@@ -732,12 +732,6 @@ class SysLogHandler(logging.Handler):
self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
self.socket.connect(address)
- # curious: when talking to the unix-domain '/dev/log' socket, a
- # zero-terminator seems to be required. this string is placed
- # into a class variable so that it can be overridden if
- # necessary.
- log_format_string = '<%d>%s\000'
-
def encodePriority(self, facility, priority):
"""
Encode the facility and priority. You can pass in strings or
@@ -781,14 +775,14 @@ class SysLogHandler(logging.Handler):
We need to convert record level to lowercase, maybe this will
change in the future.
"""
- msg = self.log_format_string % (
- self.encodePriority(self.facility,
- self.mapPriority(record.levelname)),
- msg)
+ prio = '<%d>' % self.encodePriority(self.facility,
+ self.mapPriority(record.levelname))
+ prio = prio.encode('utf-8')
#Message is a string. Convert to bytes as required by RFC 5424
msg = msg.encode('utf-8')
if codecs:
msg = codecs.BOM_UTF8 + msg
+ msg = prio + msg
try:
if self.unixsocket:
try: