(original) (raw)

changeset: 70739:260b84851d1f branch: 3.2 parent: 70736:d40609dd01e0 user: Vinay Sajip <vinay_sajip@yahoo.co.uk> date: Thu Jun 09 16:50:49 2011 +0100 files: Lib/logging/handlers.py Misc/NEWS description: Issue #12168: SysLogHandler now allows NUL termination to be controlled using a new 'append_nul' attribute on the handler. diff -r d40609dd01e0 -r 260b84851d1f Lib/logging/handlers.py --- a/Lib/logging/handlers.py Thu Jun 09 09:10:38 2011 -0500 +++ b/Lib/logging/handlers.py Thu Jun 09 16:50:49 2011 +0100 @@ -766,6 +766,8 @@ """ return self.priority_map.get(levelName, "warning") + append_nul = True # some old syslog daemons expect a NUL terminator + def emit(self, record): """ Emit a record. @@ -773,7 +775,9 @@ The record is formatted, and then sent to the syslog server. If 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 change in the future. diff -r d40609dd01e0 -r 260b84851d1f Misc/NEWS --- a/Misc/NEWS Thu Jun 09 09:10:38 2011 -0500 +++ b/Misc/NEWS Thu Jun 09 16:50:49 2011 +0100 @@ -22,6 +22,9 @@ 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 instead of os.stat. </vinay_sajip@yahoo.co.uk>