Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 40d9a4e

Browse files
committed
Improved logging.Formatter date/time formatting documentation.
1 parent 33a2994 commit 40d9a4e

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

Doc/library/logging.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,14 @@ order::
319319

320320
"%(asctime)s - %(levelname)s - %(message)s"
321321

322+
Formatters use a user-configurable function to convert the creation time of a
323+
record to a tuple. By default, :func:`time.localtime` is used; to change this
324+
for a particular formatter instance, set the ``converter`` attribute of the
325+
instance to a function with the same signature as :func:`time.localtime` or
326+
:func:`time.gmtime`. To change it for all formatters, for example if you want
327+
all logging times to be shown in GMT, set the ``converter`` attribute in the
328+
Formatter class (to ``time.gmtime`` for GMT display).
329+
322330

323331
Configuring Logging
324332
^^^^^^^^^^^^^^^^^^^

Lib/logging/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,11 @@ def formatException(self, ei):
433433
traceback.print_exception()
434434
"""
435435
sio = io.StringIO()
436-
traceback.print_exception(ei[0], ei[1], ei[2], None, sio)
436+
tb = ei[2]
437+
# See issues #9427, #1553375. Commented out for now.
438+
#if getattr(self, 'fullstack', False):
439+
# traceback.print_stack(tb.tb_frame.f_back, file=sio)
440+
traceback.print_exception(ei[0], ei[1], tb, None, sio)
437441
s = sio.getvalue()
438442
sio.close()
439443
if s[-1:] == "\n":

0 commit comments

Comments
 (0)