From 97f9cfc0b05cd00ada984eed6514b96546fb30a1 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Thu, 13 Jun 2013 22:56:36 -0400 Subject: [PATCH] ENH: 'heavydebug' level == 5 for even more debugging in tricky cases I mocked logging library directly -- seems to be Ok. --- common/__init__.py | 5 +++++ fail2ban-testcases | 5 +++-- server/filter.py | 4 ++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/common/__init__.py b/common/__init__.py index 2b76f4b6d..3eae8ee36 100644 --- a/common/__init__.py +++ b/common/__init__.py @@ -23,3 +23,8 @@ __author__ = "Cyril Jaquier" __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" + +import logging + +# Custom debug level +logging.HEAVYDEBUG = 5 diff --git a/fail2ban-testcases b/fail2ban-testcases index 0bd70259a..fc5cc1462 100755 --- a/fail2ban-testcases +++ b/fail2ban-testcases @@ -52,7 +52,7 @@ def get_opt_parser(): p.add_options([ Option('-l', "--log-level", type="choice", dest="log_level", - choices=('debug', 'info', 'warn', 'error', 'fatal'), + choices=('heavydebug', 'debug', 'info', 'warning', 'error', 'fatal'), default=None, help="Log level for the logger to use during running tests"), Option('-n', "--no-network", action="store_true", @@ -76,7 +76,8 @@ parser = get_opt_parser() logSys = logging.getLogger("fail2ban") # Numerical level of verbosity corresponding to a log "level" -verbosity = {'debug': 3, +verbosity = {'heavydebug': 4, + 'debug': 3, 'info': 2, 'warn': 1, 'error': 1, diff --git a/server/filter.py b/server/filter.py index 90530f923..59e612ede 100644 --- a/server/filter.py +++ b/server/filter.py @@ -291,6 +291,8 @@ class Filter(JailThread): except UnicodeDecodeError: l = line l = l.rstrip('\r\n') + + logSys.log(5, "Working on line %r", l) timeMatch = self.dateDetector.matchTime(l) if timeMatch: # Lets split into time part and log part of the line @@ -355,6 +357,8 @@ class Filter(JailThread): if failRegex.hasMatched(): # The failregex matched. date = self.dateDetector.getUnixTime(timeLine) + logSys.log(7, "Date: %r, message: %r", + timeLine, logLine) if date is None: logSys.debug("Found a match for %r but no valid date/time " "found for %r. Please file a detailed issue on"