Issue #7077: Fixed SysLogHandler implementation of Unicode handling.
This commit is contained in:
parent
12844e6df6
commit
467d12fcb2
|
@ -732,12 +732,6 @@ class SysLogHandler(logging.Handler):
|
||||||
self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||||
self.socket.connect(address)
|
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):
|
def encodePriority(self, facility, priority):
|
||||||
"""
|
"""
|
||||||
Encode the facility and priority. You can pass in strings or
|
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
|
We need to convert record level to lowercase, maybe this will
|
||||||
change in the future.
|
change in the future.
|
||||||
"""
|
"""
|
||||||
msg = self.log_format_string % (
|
prio = '<%d>' % self.encodePriority(self.facility,
|
||||||
self.encodePriority(self.facility,
|
self.mapPriority(record.levelname))
|
||||||
self.mapPriority(record.levelname)),
|
prio = prio.encode('utf-8')
|
||||||
msg)
|
|
||||||
#Message is a string. Convert to bytes as required by RFC 5424
|
#Message is a string. Convert to bytes as required by RFC 5424
|
||||||
msg = msg.encode('utf-8')
|
msg = msg.encode('utf-8')
|
||||||
if codecs:
|
if codecs:
|
||||||
msg = codecs.BOM_UTF8 + msg
|
msg = codecs.BOM_UTF8 + msg
|
||||||
|
msg = prio + msg
|
||||||
try:
|
try:
|
||||||
if self.unixsocket:
|
if self.unixsocket:
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue