Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions Lib/logging/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -801,16 +801,9 @@ def filter(self, record):

Allow filters to be just callables.
"""
rv = True
for f in self.filters:
if hasattr(f, 'filter'):
result = f.filter(record)
else:
result = f(record) # assume callable - will raise if not
if not result:
rv = False
break
return rv
filters = (getattr(f, 'filter', f) for f in self.filters)
return all(f(record) for f in filters) # assume callable - will raise if not
Comment thread
dwvisser marked this conversation as resolved.


#---------------------------------------------------------------------------
# Handler classes and functions
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improved the efficiency of :mod:`logging` record filtering.