Issue #12168: SysLogHandler now allows NUL termination to be controlled using a new 'append_nul' attribute on the handler.

This commit is contained in:
Vinay Sajip 2011-06-09 16:50:49 +01:00
parent 95d028fd18
commit 8168d10ea6
2 changed files with 8 additions and 1 deletions

View file

@ -766,6 +766,8 @@ class SysLogHandler(logging.Handler):
""" """
return self.priority_map.get(levelName, "warning") return self.priority_map.get(levelName, "warning")
append_nul = True # some old syslog daemons expect a NUL terminator
def emit(self, record): def emit(self, record):
""" """
Emit a record. Emit a record.
@ -773,7 +775,9 @@ class SysLogHandler(logging.Handler):
The record is formatted, and then sent to the syslog server. If The record is formatted, and then sent to the syslog server. If
exception information is present, it is NOT sent to the server. exception information is present, it is NOT sent to the server.
""" """
msg = self.format(record) + '\000' msg = self.format(record)
if self.append_nul:
msg += '\000'
""" """
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.

View file

@ -22,6 +22,9 @@ Core and Builtins
Library Library
------- -------
- Issue #12168: SysLogHandler now allows NUL termination to be controlled using
a new 'append_nul' attribute on the handler.
- Issue #11583: Speed up os.path.isdir on Windows by using GetFileAttributes - Issue #11583: Speed up os.path.isdir on Windows by using GetFileAttributes
instead of os.stat. instead of os.stat.