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

Skip to content

Commit f29839e

Browse files
committed
Issue #17007: Merged doc update from 3.2.
2 parents 5292301 + 6c4c16c commit f29839e

1 file changed

Lines changed: 29 additions & 12 deletions

File tree

Doc/library/logging.rst

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,25 @@ is the module's name in the Python package namespace.
7070

7171
.. attribute:: Logger.propagate
7272

73-
If this evaluates to true, logging messages are passed by this logger and by
74-
its child loggers to the handlers of higher level (ancestor) loggers.
75-
Messages are passed directly to the ancestor loggers' handlers - neither the
76-
level nor filters of the ancestor loggers in question are considered.
73+
If this evaluates to true, events logged to this logger will be passed to the
74+
handlers of higher level (ancestor) loggers, in addition to any handlers
75+
attached to this logger. Messages are passed directly to the ancestor
76+
loggers' handlers - neither the level nor filters of the ancestor loggers in
77+
question are considered.
7778

7879
If this evaluates to false, logging messages are not passed to the handlers
7980
of ancestor loggers.
8081

8182
The constructor sets this attribute to ``True``.
8283

84+
.. note:: If you attach a handler to several loggers, it may emit the same
85+
record multiple times. In general, you should not need to attach a
86+
handler to more than one logger - if you just attach it to the
87+
appropriate logger which is highest in the logger hierarchy, then it
88+
will see all events logged by all descendant loggers, provided that
89+
their propagate setting is left set to ``True``. A common scenario is to
90+
attach handlers only to the root logger, and let propagation take care of
91+
the rest.
8392

8493
.. method:: Logger.setLevel(lvl)
8594

@@ -255,7 +264,10 @@ is the module's name in the Python package namespace.
255264
.. method:: Logger.filter(record)
256265

257266
Applies this logger's filters to the record and returns a true value if the
258-
record is to be processed.
267+
record is to be processed. The filters are consulted in turn, until one of
268+
them returns a false value. If none of them return a false value, the record
269+
will be processed (passed to handlers). If one returns a false value, no
270+
further processing of the record occurs.
259271

260272

261273
.. method:: Logger.addHandler(hdlr)
@@ -364,7 +376,10 @@ subclasses. However, the :meth:`__init__` method in subclasses needs to call
364376
.. method:: Handler.filter(record)
365377

366378
Applies this handler's filters to the record and returns a true value if the
367-
record is to be processed.
379+
record is to be processed. The filters are consulted in turn, until one of
380+
them returns a false value. If none of them return a false value, the record
381+
will be emitted. If one returns a false value, the handler will not emit the
382+
record.
368383

369384

370385
.. method:: Handler.flush()
@@ -547,12 +562,12 @@ empty string, all events are passed.
547562
yes. If deemed appropriate, the record may be modified in-place by this
548563
method.
549564

550-
Note that filters attached to handlers are consulted whenever an event is
565+
Note that filters attached to handlers are consulted before an event is
551566
emitted by the handler, whereas filters attached to loggers are consulted
552-
whenever an event is logged to the handler (using :meth:`debug`, :meth:`info`,
553-
etc.) This means that events which have been generated by descendant loggers
554-
will not be filtered by a logger's filter setting, unless the filter has also
555-
been applied to those descendant loggers.
567+
whenever an event is logged (using :meth:`debug`, :meth:`info`,
568+
etc.), before sending an event to handlers. This means that events which have
569+
been generated by descendant loggers will not be filtered by a logger's filter
570+
setting, unless the filter has also been applied to those descendant loggers.
556571

557572
You don't actually need to subclass ``Filter``: you can pass any instance
558573
which has a ``filter`` method with the same semantics.
@@ -596,7 +611,9 @@ wire).
596611
record.
597612

598613
:param name: The name of the logger used to log the event represented by
599-
this LogRecord.
614+
this LogRecord. Note that this name will always have this
615+
value, even though it may be emitted by a handler attached to
616+
a different (ancestor) logger.
600617
:param level: The numeric level of the logging event (one of DEBUG, INFO etc.)
601618
Note that this is converted to *two* attributes of the LogRecord:
602619
``levelno`` for the numeric value and ``levelname`` for the

0 commit comments

Comments
 (0)