diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2010-10-20 20:05:38 (GMT) |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2010-10-20 20:05:38 (GMT) |
commit | 2a20dfc2aabc3259d5b4276eeec91f83230fdcac (patch) | |
tree | 35e3ce7c976c4c969fad1fc4dbf2d1aee48255e9 /Lib/logging/__init__.py | |
parent | f3500e119865b28c34ffacb9f582db49b9d70e9d (diff) | |
download | cpython-2a20dfc2aabc3259d5b4276eeec91f83230fdcac.zip cpython-2a20dfc2aabc3259d5b4276eeec91f83230fdcac.tar.gz cpython-2a20dfc2aabc3259d5b4276eeec91f83230fdcac.tar.bz2 |
logging: Made StreamHandler terminator configurable.
Diffstat (limited to 'Lib/logging/__init__.py')
-rw-r--r-- | Lib/logging/__init__.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index 03ceb9c..7f217d4 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -359,7 +359,7 @@ class Formatter(object): responsible for converting a LogRecord to (usually) a string which can 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 - 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 knowledge of the LogRecord attributes - e.g. the default value mentioned @@ -823,6 +823,8 @@ class StreamHandler(Handler): sys.stdout or sys.stderr may be used. """ + terminator = '\n' + def __init__(self, stream=None): """ Initialize the handler. @@ -855,8 +857,8 @@ class StreamHandler(Handler): try: msg = self.format(record) stream = self.stream - fs = "%s\n" - stream.write(fs % msg) + stream.write(msg) + stream.write(self.terminator) self.flush() except (KeyboardInterrupt, SystemExit): raise |