[issue41906] logging.config.dictConfig does not work with callable filters
Vinay Sajip
report at bugs.python.org
Fri Oct 2 03:19:22 EDT 2020
Vinay Sajip <vinay_sajip at yahoo.co.uk> added the comment:
The value of the '()' key should be a factory - something that returns a filter (either something that has a filter method or a callable). That returned callable, or the filter method, will be called with a LogRecord and its return value used to determine whether the event should be processed. An example of using factories is here:
https://docs.python.org/3/library/logging.config.html#user-defined-objects
In your first example, you're passing the filter where you need to pass the factory. If you change it to e.g. return a lambda that does the filtering, it should work as expected.
At the moment you can't directly pass a filter callable in the config dictionary - only a factory that returns a filter. I'll look at this as a possible enhancement.
----------
type: behavior -> enhancement
versions: +Python 3.10
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41906>
_______________________________________
More information about the Python-bugs-list
mailing list