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

Skip to content

Commit c46102c

Browse files
committed
Updated Formatter documentation.
1 parent 2e3607c commit c46102c

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

Doc/library/logging.rst

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,14 +405,22 @@ The useful mapping keys in a :class:`LogRecord` are given in the section on
405405
:ref:`logrecord-attributes`.
406406

407407

408-
.. class:: Formatter(fmt=None, datefmt=None)
408+
.. class:: Formatter(fmt=None, datefmt=None, style='%')
409409

410410
Returns a new instance of the :class:`Formatter` class. The instance is
411411
initialized with a format string for the message as a whole, as well as a
412412
format string for the date/time portion of a message. If no *fmt* is
413413
specified, ``'%(message)s'`` is used. If no *datefmt* is specified, the
414414
ISO8601 date format is used.
415415

416+
The *style* parameter can be one of '%', '{' or '$' and determines how
417+
the format string will be merged with its data: using one of %-formatting,
418+
:meth:`str.format` or :class:`string.Template`.
419+
420+
.. versionchanged:: 3.2
421+
The *style* parameter was added.
422+
423+
416424
.. method:: format(record)
417425

418426
The record's attribute dictionary is used as the operand to a string
@@ -691,7 +699,6 @@ LoggerAdapter Objects
691699
information into logging calls. For a usage example , see the section on
692700
:ref:`adding contextual information to your logging output <context-info>`.
693701

694-
695702
.. class:: LoggerAdapter(logger, extra)
696703

697704
Returns an instance of :class:`LoggerAdapter` initialized with an

0 commit comments

Comments
 (0)