Closes #12419: Added ident to SysLogHandler.
diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py
index 5779a7d..ef17081 100644
--- a/Lib/logging/handlers.py
+++ b/Lib/logging/handlers.py
@@ -769,6 +769,7 @@
"""
return self.priority_map.get(levelName, "warning")
+ ident = '' # prepended to all messages
append_nul = True # some old syslog daemons expect a NUL terminator
def emit(self, record):
@@ -779,6 +780,8 @@
exception information is present, it is NOT sent to the server.
"""
msg = self.format(record)
+ if self.ident:
+ msg = self.ident + msg
if self.append_nul:
msg += '\000'
"""
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
index b0b8e19..5d84114 100644
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -1482,6 +1482,11 @@
logger.error("sp\xe4m")
self.handled.wait()
self.assertEqual(self.log_output, b'<11>\xef\xbb\xbfsp\xc3\xa4m')
+ self.handled.clear()
+ self.sl_hdlr.ident = "h\xe4m-"
+ logger.error("sp\xe4m")
+ self.handled.wait()
+ self.assertEqual(self.log_output, b'<11>\xef\xbb\xbfh\xc3\xa4m-sp\xc3\xa4m')
@unittest.skipUnless(threading, 'Threading required for this test.')