1
0
Fork 0
forked from github/pelican

Fix LOG_FILTER to act on exact messages

* Adds the ability to filter templated messages by exact message,
as well as templates.
* Adds a test for LimitFilter.

Fixes #2552,  #2682
This commit is contained in:
Deniz Turgut 2020-04-12 20:56:07 +03:00
commit 97dbafcb89
2 changed files with 83 additions and 3 deletions

View file

@ -110,11 +110,13 @@ class LimitFilter(logging.Filter):
else:
self._raised_messages.add(message_key)
# ignore LOG_FILTER records by templates when "debug" isn't enabled
# ignore LOG_FILTER records by templates or messages
# when "debug" isn't enabled
logger_level = logging.getLogger().getEffectiveLevel()
if logger_level > logging.DEBUG:
ignore_key = (record.levelno, record.msg)
if ignore_key in self._ignore:
template_key = (record.levelno, record.msg)
message_key = (record.levelno, record.getMessage())
if (template_key in self._ignore or message_key in self._ignore):
return False
# check if we went over threshold