From cc7a8000e74c09ac2a747cf303ff86a48f37ec1e Mon Sep 17 00:00:00 2001 From: Omar Pakker Date: Mon, 16 Sep 2024 18:10:50 +0200 Subject: [PATCH] Fixed logging filter bug introduced in 1.4.4 --- bazarr/app/logger.py | 2 +- tests/test_logging_filters.py | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 tests/test_logging_filters.py diff --git a/bazarr/app/logger.py b/bazarr/app/logger.py index 8803ad3cb..e5f2fce7d 100644 --- a/bazarr/app/logger.py +++ b/bazarr/app/logger.py @@ -62,7 +62,7 @@ class UnwantedWaitressMessageFilter(logging.Filter): # no filtering in debug mode or if originating from us return True - if record.level != loggin.ERROR: + if record.level < logging.ERROR: return False unwantedMessages = [ diff --git a/tests/test_logging_filters.py b/tests/test_logging_filters.py new file mode 100644 index 000000000..9209fb09e --- /dev/null +++ b/tests/test_logging_filters.py @@ -0,0 +1,22 @@ +import logging + +from bazarr.app.logger import UnwantedWaitressMessageFilter + +def test_true_for_bazarr(): + record = logging.makeLogRecord({ + "level": logging.INFO, + "msg": "a message from BAZARR for logging" + }) + assert UnwantedWaitressMessageFilter().filter(record) + +def test_false_below_error(): + record = logging.makeLogRecord({ + "level": logging.INFO + }) + assert not UnwantedWaitressMessageFilter().filter(record) + +def test_true_error_up(): + record = logging.makeLogRecord({ + "level": logging.CRITICAL + }) + assert UnwantedWaitressMessageFilter().filter(record)