From ac41b8f3be61fedf6cea724d4d1775c07d2045da Mon Sep 17 00:00:00 2001 From: sebres Date: Wed, 8 Jan 2020 21:43:27 +0100 Subject: [PATCH] some logging level got changed between 0.10/0.11 (9 is lowest log level to capture messages in LogCaptureTestCase now) --- fail2ban/server/action.py | 2 +- fail2ban/tests/utils.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/fail2ban/server/action.py b/fail2ban/server/action.py index 29dc245f..d7812b6d 100644 --- a/fail2ban/server/action.py +++ b/fail2ban/server/action.py @@ -1008,7 +1008,7 @@ class CommandAction(ActionBase): RuntimeError If command execution times out. """ - if logSys.getEffectiveLevel() < logging.DEBUG: # pragma: no cover + if logSys.getEffectiveLevel() < logging.DEBUG: logSys.log(9, realCmd) if not realCmd: logSys.debug("Nothing to do") diff --git a/fail2ban/tests/utils.py b/fail2ban/tests/utils.py index 9074da6d..fcfddba7 100644 --- a/fail2ban/tests/utils.py +++ b/fail2ban/tests/utils.py @@ -754,10 +754,11 @@ class LogCaptureTestCase(unittest.TestCase): # Let's log everything into a string self._log = LogCaptureTestCase._MemHandler(unittest.F2B.log_lazy) logSys.handlers = [self._log] - if self._old_level <= logging.DEBUG: + # lowest log level to capture messages (expected in tests) is Lev.9 + if self._old_level <= logging.DEBUG: # pragma: no cover logSys.handlers += self._old_handlers - else: # lowest log level to capture messages - logSys.setLevel(logging.DEBUG) + if self._old_level > logging.DEBUG-1: + logSys.setLevel(logging.DEBUG-1) super(LogCaptureTestCase, self).setUp() def tearDown(self):