mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Made time formats in Formatter more configurable.
This commit is contained in:
parent
8dd8d582e3
commit
ae5740f139
1 changed files with 5 additions and 2 deletions
|
@ -467,6 +467,9 @@ class Formatter(object):
|
||||||
self._fmt = self._style._fmt
|
self._fmt = self._style._fmt
|
||||||
self.datefmt = datefmt
|
self.datefmt = datefmt
|
||||||
|
|
||||||
|
default_time_format = '%Y-%m-%d %H:%M:%S'
|
||||||
|
default_msec_format = '%s,%03d'
|
||||||
|
|
||||||
def formatTime(self, record, datefmt=None):
|
def formatTime(self, record, datefmt=None):
|
||||||
"""
|
"""
|
||||||
Return the creation time of the specified LogRecord as formatted text.
|
Return the creation time of the specified LogRecord as formatted text.
|
||||||
|
@ -489,8 +492,8 @@ class Formatter(object):
|
||||||
if datefmt:
|
if datefmt:
|
||||||
s = time.strftime(datefmt, ct)
|
s = time.strftime(datefmt, ct)
|
||||||
else:
|
else:
|
||||||
t = time.strftime("%Y-%m-%d %H:%M:%S", ct)
|
t = time.strftime(self.default_time_format, ct)
|
||||||
s = "%s,%03d" % (t, record.msecs) # the use of % here is internal
|
s = self.default_msec_format % (t, record.msecs)
|
||||||
return s
|
return s
|
||||||
|
|
||||||
def formatException(self, ei):
|
def formatException(self, ei):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue