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

Skip to content

Commit 22246fd

Browse files
committed
logging: clarified Filter documentation.
1 parent 9450cc0 commit 22246fd

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

Doc/library/logging.rst

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3068,14 +3068,18 @@ etc.) This means that events which have been generated by descendant loggers
30683068
will not be filtered by a logger's filter setting, unless the filter has also
30693069
been applied to those descendant loggers.
30703070

3071+
You don't actually need to subclass ``Filter``: you can pass any instance
3072+
which has a ``filter`` method with the same semantics.
3073+
30713074
.. versionchanged:: 3.2
30723075

3073-
You don't need to create specialized ``Filter`` classes: you can use a plain
3074-
function (or other callable) as a filter. The filtering logic will check to
3075-
see if the filter object has a ``filter`` attribute: if it does, it's assumed
3076-
to be a ``Filter`` and its :meth:`~Filter.filter` method is called. Otherwise,
3077-
it's assumed to be a callable and called with the record as the single
3078-
parameter. The result should conform to that of :meth:`~Filter.filter`.
3076+
You don't need to create specialized ``Filter`` classes, or use other classes
3077+
with a ``filter`` method: you can use a function (or other callable) as a
3078+
filter. The filtering logic will check to see if the filter object has a
3079+
``filter`` attribute: if it does, it's assumed to be a ``Filter`` and its
3080+
:meth:`~Filter.filter` method is called. Otherwise, it's assumed to be a
3081+
callable and called with the record as the single parameter. The returned
3082+
value should conform to that returned by :meth:`~Filter.filter`.
30793083

30803084
Other uses for filters
30813085
^^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)