[Python-checkins] r85755 - in python/branches/py3k: Lib/logging/__init__.py Misc/NEWS

vinay.sajip python-checkins at python.org
Wed Oct 20 22:05:38 CEST 2010


Author: vinay.sajip
Date: Wed Oct 20 22:05:38 2010
New Revision: 85755

Log:
logging: Made StreamHandler terminator configurable.

Modified:
   python/branches/py3k/Lib/logging/__init__.py
   python/branches/py3k/Misc/NEWS

Modified: python/branches/py3k/Lib/logging/__init__.py
==============================================================================
--- python/branches/py3k/Lib/logging/__init__.py	(original)
+++ python/branches/py3k/Lib/logging/__init__.py	Wed Oct 20 22:05:38 2010
@@ -359,7 +359,7 @@
     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 @@
     sys.stdout or sys.stderr may be used.
     """
 
+    terminator = '\n'
+
     def __init__(self, stream=None):
         """
         Initialize the handler.
@@ -855,8 +857,8 @@
         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

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Wed Oct 20 22:05:38 2010
@@ -34,6 +34,8 @@
 Library
 -------
 
+- logging: Made StreamHandler terminator configurable.
+
 - logging: Allowed filters to be just callables.
 
 - logging: Added tests for _logRecordClass changes.


More information about the Python-checkins mailing list