mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
parent
5cc4c9f4ab
commit
1b1d1fd9f7
2 changed files with 21 additions and 4 deletions
|
|
@ -777,6 +777,16 @@ be filtered out.
|
|||
|
||||
For example: ``[(logging.WARN, 'TAG_SAVE_AS is set to False')]``
|
||||
|
||||
It is possible to filter out messages by a template. Check out source code to
|
||||
obtain a template.
|
||||
|
||||
For example: ``[(logging.WARN, 'Empty alt attribute for image %s in %s')]``
|
||||
|
||||
**Warning:** Silencing messages by templates is a dangerous feature. It is
|
||||
possible to unintentionally filter out multiple message types with the same
|
||||
template (including messages from future Pelican versions). Proceed with
|
||||
caution.
|
||||
|
||||
.. _reading_only_modified_content:
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ class LimitFilter(logging.Filter):
|
|||
"""
|
||||
|
||||
_ignore = set()
|
||||
_raised_messages = set()
|
||||
_threshold = 5
|
||||
_group_count = defaultdict(int)
|
||||
|
||||
|
|
@ -105,12 +106,18 @@ class LimitFilter(logging.Filter):
|
|||
group_args = record.__dict__.get('limit_args', ())
|
||||
|
||||
# ignore record if it was already raised
|
||||
# use .getMessage() and not .msg for string formatting
|
||||
ignore_key = (record.levelno, record.getMessage())
|
||||
if ignore_key in self._ignore:
|
||||
message_key = (record.levelno, record.getMessage())
|
||||
if message_key in self._raised_messages:
|
||||
return False
|
||||
else:
|
||||
self._ignore.add(ignore_key)
|
||||
self._raised_messages.add(message_key)
|
||||
|
||||
# ignore LOG_FILTER records
|
||||
# use .msg and not .getMessage() for string formatting to allow
|
||||
# filtering by templates
|
||||
ignore_key = (record.levelno, record.msg)
|
||||
if ignore_key in self._ignore:
|
||||
return False
|
||||
|
||||
# check if we went over threshold
|
||||
if group:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue