mirror of
https://github.com/python/cpython.git
synced 2025-11-02 03:01:58 +00:00
bpo-41906: Accept built filters in dictConfig (GH-30756)
When configuring the logging stack, accept already built filters (or just callables) in the filters array of loggers and handlers. This facilitates passing quick callables as filters. Automerge-Triggered-By: GH:vsajip
This commit is contained in:
parent
58f3d98098
commit
d7c6863979
4 changed files with 55 additions and 1 deletions
|
|
@ -694,7 +694,11 @@ class DictConfigurator(BaseConfigurator):
|
|||
"""Add filters to a filterer from a list of names."""
|
||||
for f in filters:
|
||||
try:
|
||||
filterer.addFilter(self.config['filters'][f])
|
||||
if callable(f) or callable(getattr(f, 'filter', None)):
|
||||
filter_ = f
|
||||
else:
|
||||
filter_ = self.config['filters'][f]
|
||||
filterer.addFilter(filter_)
|
||||
except Exception as e:
|
||||
raise ValueError('Unable to add filter %r' % f) from e
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue