Commit 2a20dfc2 authored by Vinay Sajip's avatar Vinay Sajip

logging: Made StreamHandler terminator configurable.

parent f3500e11
...@@ -359,7 +359,7 @@ class Formatter(object): ...@@ -359,7 +359,7 @@ class Formatter(object):
responsible for converting a LogRecord to (usually) a string which can responsible for converting a LogRecord to (usually) a string which can
be interpreted by either a human or an external system. The base Formatter be interpreted by either a human or an external system. The base Formatter
allows a formatting string to be specified. If none is supplied, the allows a formatting string to be specified. If none is supplied, the
default value of "%s(message)\\n" is used. default value of "%s(message)" is used.
The Formatter can be initialized with a format string which makes use of The Formatter can be initialized with a format string which makes use of
knowledge of the LogRecord attributes - e.g. the default value mentioned knowledge of the LogRecord attributes - e.g. the default value mentioned
...@@ -823,6 +823,8 @@ class StreamHandler(Handler): ...@@ -823,6 +823,8 @@ class StreamHandler(Handler):
sys.stdout or sys.stderr may be used. sys.stdout or sys.stderr may be used.
""" """
terminator = '\n'
def __init__(self, stream=None): def __init__(self, stream=None):
""" """
Initialize the handler. Initialize the handler.
...@@ -855,8 +857,8 @@ class StreamHandler(Handler): ...@@ -855,8 +857,8 @@ class StreamHandler(Handler):
try: try:
msg = self.format(record) msg = self.format(record)
stream = self.stream stream = self.stream
fs = "%s\n" stream.write(msg)
stream.write(fs % msg) stream.write(self.terminator)
self.flush() self.flush()
except (KeyboardInterrupt, SystemExit): except (KeyboardInterrupt, SystemExit):
raise raise
......
...@@ -34,6 +34,8 @@ Core and Builtins ...@@ -34,6 +34,8 @@ Core and Builtins
Library Library
------- -------
- logging: Made StreamHandler terminator configurable.
- logging: Allowed filters to be just callables. - logging: Allowed filters to be just callables.
- logging: Added tests for _logRecordClass changes. - logging: Added tests for _logRecordClass changes.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment