Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8168d10

Browse files
committed
Issue #12168: SysLogHandler now allows NUL termination to be controlled using a new 'append_nul' attribute on the handler.
1 parent 95d028f commit 8168d10

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

Lib/logging/handlers.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,14 +766,18 @@ def mapPriority(self, levelName):
766766
"""
767767
return self.priority_map.get(levelName, "warning")
768768

769+
append_nul = True # some old syslog daemons expect a NUL terminator
770+
769771
def emit(self, record):
770772
"""
771773
Emit a record.
772774
773775
The record is formatted, and then sent to the syslog server. If
774776
exception information is present, it is NOT sent to the server.
775777
"""
776-
msg = self.format(record) + '\000'
778+
msg = self.format(record)
779+
if self.append_nul:
780+
msg += '\000'
777781
"""
778782
We need to convert record level to lowercase, maybe this will
779783
change in the future.

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ Core and Builtins
2222
Library
2323
-------
2424

25+
- Issue #12168: SysLogHandler now allows NUL termination to be controlled using
26+
a new 'append_nul' attribute on the handler.
27+
2528
- Issue #11583: Speed up os.path.isdir on Windows by using GetFileAttributes
2629
instead of os.stat.
2730

0 commit comments

Comments
 (0)