summaryrefslogtreecommitdiffstats
path: root/Lib/logging
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2011-06-09 17:42:19 (GMT)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2011-06-09 17:42:19 (GMT)
commitae5740f139304a2d032602f17b87ec485aa4c750 (patch)
tree55e80974459269f1d20699f7cad6e678bd6415dc /Lib/logging
parent8dd8d582e3c6d1dd80f5b958284fcb7260209bf3 (diff)
downloadcpython-ae5740f139304a2d032602f17b87ec485aa4c750.zip
cpython-ae5740f139304a2d032602f17b87ec485aa4c750.tar.gz
cpython-ae5740f139304a2d032602f17b87ec485aa4c750.tar.bz2
Made time formats in Formatter more configurable.
Diffstat (limited to 'Lib/logging')
-rw-r--r--Lib/logging/__init__.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
index 1a4b241..509dae6 100644
--- a/Lib/logging/__init__.py
+++ b/Lib/logging/__init__.py
@@ -467,6 +467,9 @@ class Formatter(object):
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 @@ class Formatter(object):
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):