Skip to content

Commit 24b3d02

Browse files
committed
pythongh-84095: Fill documentation gap regarding user-defined objects. (pythonGH-96574)
(cherry picked from commit a9d58fe)
1 parent f5a7847 commit 24b3d02

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

Doc/library/logging.config.rst

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,25 @@ valid keyword parameter name, and so will not clash with the names of
524524
the keyword arguments used in the call. The ``'()'`` also serves as a
525525
mnemonic that the corresponding value is a callable.
526526

527+
You can also specify a special key ``'.'`` whose value is a dictionary is a
528+
mapping of attribute names to values. If found, the specified attributes will
529+
be set on the user-defined object before it is returned. Thus, with the
530+
following configuration::
531+
532+
{
533+
'()' : 'my.package.customFormatterFactory',
534+
'bar' : 'baz',
535+
'spam' : 99.9,
536+
'answer' : 42,
537+
'.' {
538+
'foo': 'bar',
539+
'baz': 'bozz'
540+
}
541+
}
542+
543+
the returned formatter will have attribute ``foo`` set to ``'bar'`` and
544+
attribute ``baz`` set to ``'bozz'``.
545+
527546

528547
.. _logging-config-dict-externalobj:
529548

@@ -706,7 +725,7 @@ root logger section is given below.
706725
707726
The ``level`` entry can be one of ``DEBUG, INFO, WARNING, ERROR, CRITICAL`` or
708727
``NOTSET``. For the root logger only, ``NOTSET`` means that all messages will be
709-
logged. Level values are :func:`eval`\ uated in the context of the ``logging``
728+
logged. Level values are :ref:`evaluated <func-eval>` in the context of the ``logging``
710729
package's namespace.
711730

712731
The ``handlers`` entry is a comma-separated list of handler names, which must
@@ -753,13 +772,13 @@ handler. If blank, a default formatter (``logging._defaultFormatter``) is used.
753772
If a name is specified, it must appear in the ``[formatters]`` section and have
754773
a corresponding section in the configuration file.
755774

756-
The ``args`` entry, when :func:`eval`\ uated in the context of the ``logging``
775+
The ``args`` entry, when :ref:`evaluated <func-eval>` in the context of the ``logging``
757776
package's namespace, is the list of arguments to the constructor for the handler
758777
class. Refer to the constructors for the relevant handlers, or to the examples
759778
below, to see how typical entries are constructed. If not provided, it defaults
760779
to ``()``.
761780

762-
The optional ``kwargs`` entry, when :func:`eval`\ uated in the context of the
781+
The optional ``kwargs`` entry, when :ref:`evaluated <func-eval>` in the context of the
763782
``logging`` package's namespace, is the keyword argument dict to the constructor
764783
for the handler class. If not provided, it defaults to ``{}``.
765784

@@ -823,7 +842,7 @@ Sections which specify formatter configuration are typified by the following.
823842
[formatter_form01]
824843
format=F1 %(asctime)s %(levelname)s %(message)s
825844
datefmt=
826-
style='%'
845+
style=%
827846
validate=True
828847
class=logging.Formatter
829848

0 commit comments

Comments
 (0)