[Python-checkins] cpython: Made time formats in Formatter more configurable.

vinay.sajip python-checkins at python.org
Thu Jun 9 19:43:21 CEST 2011


http://hg.python.org/cpython/rev/8582d5ea9aaa
changeset: 70742:8582d5ea9aaa
parent: 70740:ac1217099b3f
user: Vinay Sajip <vinay_sajip at yahoo.co.uk>
date: Thu Jun 09 18:42:19 2011 +0100
summary:
 Made time formats in Formatter more configurable.
files:
 Lib/logging/__init__.py | 7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
--- a/Lib/logging/__init__.py
+++ b/Lib/logging/__init__.py
@@ -467,6 +467,9 @@
 self._fmt = self._style._fmt
 self.datefmt = datefmt
 
+ default_time_format = '%Y-%m-%d %H:%M:%S'
+ default_msec_format = '%s,%03d'
+
 def formatTime(self, record, datefmt=None):
 """
 Return the creation time of the specified LogRecord as formatted text.
@@ -489,8 +492,8 @@
 if datefmt:
 s = time.strftime(datefmt, ct)
 else:
- t = time.strftime("%Y-%m-%d %H:%M:%S", ct)
- s = "%s,%03d" % (t, record.msecs) # the use of % here is internal
+ t = time.strftime(self.default_time_format, ct)
+ s = self.default_msec_format % (t, record.msecs)
 return s
 
 def formatException(self, ei):
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /