From 4fc7f1a831062e2caa2ef81d3677bff8b3a2d34a Mon Sep 17 00:00:00 2001 From: Steven Hiscocks Date: Tue, 10 Jun 2014 20:36:19 +0100 Subject: [PATCH] ENH: Tweak naming of getF2BLogger, and ensure consistent use --- bin/fail2ban-client | 3 ++- bin/fail2ban-regex | 4 ++-- bin/fail2ban-server | 5 +++-- bin/fail2ban-testcases | 6 +++--- fail2ban/client/actionreader.py | 4 ++-- fail2ban/client/beautifier.py | 4 ++-- fail2ban/client/configparserinc.py | 4 ++-- fail2ban/client/configreader.py | 4 ++-- fail2ban/client/configurator.py | 4 ++-- fail2ban/client/fail2banreader.py | 4 ++-- fail2ban/client/filterreader.py | 4 ++-- fail2ban/client/jailreader.py | 4 ++-- fail2ban/client/jailsreader.py | 4 ++-- fail2ban/helpers.py | 4 ++-- fail2ban/server/action.py | 7 +++---- fail2ban/server/actions.py | 4 ++-- fail2ban/server/asyncserver.py | 4 ++-- fail2ban/server/banmanager.py | 4 ++-- fail2ban/server/database.py | 4 ++-- fail2ban/server/datedetector.py | 4 ++-- fail2ban/server/datetemplate.py | 4 ++-- fail2ban/server/faildata.py | 4 ++-- fail2ban/server/failmanager.py | 4 ++-- fail2ban/server/filter.py | 4 ++-- fail2ban/server/filtergamin.py | 4 ++-- fail2ban/server/filterpoll.py | 4 ++-- fail2ban/server/filterpyinotify.py | 4 ++-- fail2ban/server/filtersystemd.py | 4 ++-- fail2ban/server/jail.py | 4 ++-- fail2ban/server/server.py | 12 ++++++------ fail2ban/server/ticket.py | 4 ++-- fail2ban/server/transmitter.py | 4 ++-- fail2ban/tests/misctestcase.py | 4 ++-- fail2ban/tests/servertestcase.py | 7 +++---- fail2ban/tests/utils.py | 8 ++++---- 35 files changed, 80 insertions(+), 80 deletions(-) diff --git a/bin/fail2ban-client b/bin/fail2ban-client index b9713153..89e0a903 100755 --- a/bin/fail2ban-client +++ b/bin/fail2ban-client @@ -30,9 +30,10 @@ from fail2ban.protocol import printFormatted from fail2ban.client.csocket import CSocket from fail2ban.client.configurator import Configurator from fail2ban.client.beautifier import Beautifier +from fail2ban.helpers import getLogger # Gets the instance of the logger. -logSys = logging.getLogger("fail2ban") +logSys = getLogger("fail2ban") ## # diff --git a/bin/fail2ban-regex b/bin/fail2ban-regex index 3a887867..ff7e2fb7 100755 --- a/bin/fail2ban-regex +++ b/bin/fail2ban-regex @@ -45,9 +45,9 @@ from fail2ban.client.filterreader import FilterReader from fail2ban.server.filter import Filter from fail2ban.server.failregex import RegexException -from fail2ban.helpers import FormatterWithTraceBack +from fail2ban.helpers import FormatterWithTraceBack, getLogger # Gets the instance of the logger. -logSys = logging.getLogger("fail2ban") +logSys = getLogger("fail2ban") def debuggexURL(sample, regex): q = urllib.urlencode({ 're': regex.replace('', '(?&.ipv4)'), diff --git a/bin/fail2ban-server b/bin/fail2ban-server index aba19ab5..ec0c0dbe 100755 --- a/bin/fail2ban-server +++ b/bin/fail2ban-server @@ -22,13 +22,14 @@ __author__ = "Cyril Jaquier" __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" -import getopt, sys, logging, os +import getopt, sys, os from fail2ban.version import version from fail2ban.server.server import Server +from fail2ban.helpers import getLogger # Gets the instance of the logger. -logSys = logging.getLogger("fail2ban") +logSys = getLogger("fail2ban") ## # \mainpage Fail2Ban diff --git a/bin/fail2ban-testcases b/bin/fail2ban-testcases index 0e2fdb4b..8b1343a3 100755 --- a/bin/fail2ban-testcases +++ b/bin/fail2ban-testcases @@ -25,7 +25,7 @@ __copyright__ = "Copyright (c) 2004 Cyril Jaquier, 2012- Yaroslav Halchenko" __license__ = "GPL" -import unittest, logging, sys, time, os +import unittest, sys, time, os # Check if local fail2ban module exists, and use if it exists by # modifying the path. This is such that tests can be used in dev @@ -35,7 +35,7 @@ if os.path.exists("fail2ban/__init__.py"): from fail2ban.version import version from fail2ban.tests.utils import gatherTests -from fail2ban.helpers import FormatterWithTraceBack +from fail2ban.helpers import FormatterWithTraceBack, getLogger from fail2ban.server.mytime import MyTime from optparse import OptionParser, Option @@ -70,7 +70,7 @@ parser = get_opt_parser() # # Logging # -logSys = logging.getLogger("fail2ban") +logSys = getLogger("fail2ban") # Numerical level of verbosity corresponding to a log "level" verbosity = {'heavydebug': 4, diff --git a/fail2ban/client/actionreader.py b/fail2ban/client/actionreader.py index 07572930..91f3322b 100644 --- a/fail2ban/client/actionreader.py +++ b/fail2ban/client/actionreader.py @@ -27,10 +27,10 @@ __license__ = "GPL" import os from .configreader import ConfigReader, DefinitionInitConfigReader -from ..helpers import getF2BLogger +from ..helpers import getLogger # Gets the instance of the logger. -logSys = getF2BLogger(__name__) +logSys = getLogger(__name__) class ActionReader(DefinitionInitConfigReader): diff --git a/fail2ban/client/beautifier.py b/fail2ban/client/beautifier.py index 070c80c5..cf17e54f 100644 --- a/fail2ban/client/beautifier.py +++ b/fail2ban/client/beautifier.py @@ -22,10 +22,10 @@ __copyright__ = "Copyright (c) 2004 Cyril Jaquier, 2013- Yaroslav Halchenko" __license__ = "GPL" from ..exceptions import UnknownJailException, DuplicateJailException -from ..helpers import getF2BLogger +from ..helpers import getLogger # Gets the instance of the logger. -logSys = getF2BLogger(__name__) +logSys = getLogger(__name__) ## # Beautify the output of the client. diff --git a/fail2ban/client/configparserinc.py b/fail2ban/client/configparserinc.py index 1be786c7..80b99517 100644 --- a/fail2ban/client/configparserinc.py +++ b/fail2ban/client/configparserinc.py @@ -25,7 +25,7 @@ __copyright__ = 'Copyright (c) 2007 Yaroslav Halchenko' __license__ = 'GPL' import os, sys -from ..helpers import getF2BLogger +from ..helpers import getLogger if sys.version_info >= (3,2): # pragma: no cover @@ -61,7 +61,7 @@ else: # pragma: no cover from ConfigParser import SafeConfigParser # Gets the instance of the logger. -logSys = getF2BLogger(__name__) +logSys = getLogger(__name__) __all__ = ['SafeConfigParserWithIncludes'] diff --git a/fail2ban/client/configreader.py b/fail2ban/client/configreader.py index e905b278..22115d3a 100644 --- a/fail2ban/client/configreader.py +++ b/fail2ban/client/configreader.py @@ -28,10 +28,10 @@ import glob, os from ConfigParser import NoOptionError, NoSectionError from .configparserinc import SafeConfigParserWithIncludes -from ..helpers import getF2BLogger +from ..helpers import getLogger # Gets the instance of the logger. -logSys = getF2BLogger(__name__) +logSys = getLogger(__name__) class ConfigReader(SafeConfigParserWithIncludes): diff --git a/fail2ban/client/configurator.py b/fail2ban/client/configurator.py index 23c21c4b..0dd9f955 100644 --- a/fail2ban/client/configurator.py +++ b/fail2ban/client/configurator.py @@ -26,10 +26,10 @@ __license__ = "GPL" from .fail2banreader import Fail2banReader from .jailsreader import JailsReader -from ..helpers import getF2BLogger +from ..helpers import getLogger # Gets the instance of the logger. -logSys = getF2BLogger(__name__) +logSys = getLogger(__name__) class Configurator: diff --git a/fail2ban/client/fail2banreader.py b/fail2ban/client/fail2banreader.py index 4d106f3a..361a5e54 100644 --- a/fail2ban/client/fail2banreader.py +++ b/fail2ban/client/fail2banreader.py @@ -25,10 +25,10 @@ __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" from .configreader import ConfigReader -from ..helpers import getF2BLogger +from ..helpers import getLogger # Gets the instance of the logger. -logSys = getF2BLogger(__name__) +logSys = getLogger(__name__) class Fail2banReader(ConfigReader): diff --git a/fail2ban/client/filterreader.py b/fail2ban/client/filterreader.py index 2f5b3b05..40d74c45 100644 --- a/fail2ban/client/filterreader.py +++ b/fail2ban/client/filterreader.py @@ -28,10 +28,10 @@ import os, shlex from .configreader import ConfigReader, DefinitionInitConfigReader from ..server.action import CommandAction -from ..helpers import getF2BLogger +from ..helpers import getLogger # Gets the instance of the logger. -logSys = getF2BLogger(__name__) +logSys = getLogger(__name__) class FilterReader(DefinitionInitConfigReader): diff --git a/fail2ban/client/jailreader.py b/fail2ban/client/jailreader.py index 6207d8f4..a4bf5174 100644 --- a/fail2ban/client/jailreader.py +++ b/fail2ban/client/jailreader.py @@ -30,10 +30,10 @@ import json from .configreader import ConfigReader from .filterreader import FilterReader from .actionreader import ActionReader -from ..helpers import getF2BLogger +from ..helpers import getLogger # Gets the instance of the logger. -logSys = getF2BLogger(__name__) +logSys = getLogger(__name__) class JailReader(ConfigReader): diff --git a/fail2ban/client/jailsreader.py b/fail2ban/client/jailsreader.py index 86fd501f..84c614b9 100644 --- a/fail2ban/client/jailsreader.py +++ b/fail2ban/client/jailsreader.py @@ -26,10 +26,10 @@ __license__ = "GPL" from .configreader import ConfigReader from .jailreader import JailReader -from ..helpers import getF2BLogger +from ..helpers import getLogger # Gets the instance of the logger. -logSys = getF2BLogger(__name__) +logSys = getLogger(__name__) class JailsReader(ConfigReader): diff --git a/fail2ban/helpers.py b/fail2ban/helpers.py index 35c7ebc3..2c810878 100644 --- a/fail2ban/helpers.py +++ b/fail2ban/helpers.py @@ -108,7 +108,7 @@ class FormatterWithTraceBack(logging.Formatter): record.tbc = record.tb = self._tb() return logging.Formatter.format(self, record) -def getF2BLogger(name): +def getLogger(name): """Get logging.Logger instance with Fail2Ban logger name convention """ return logging.getLogger("fail2ban.%s" % name.rpartition(".")[-1]) @@ -116,6 +116,6 @@ def getF2BLogger(name): def fail2ban_excepthook(exctype, value, traceback): """Except hook used to log unhandled exceptions to Fail2Ban log """ - logging.getLogger("fail2ban").critical( + getLogger("fail2ban").critical( "Unhandled exception in Fail2Ban:", exc_info=True) return sys.__excepthook__(exctype, value, traceback) diff --git a/fail2ban/server/action.py b/fail2ban/server/action.py index ea7bc91c..e1bd719a 100644 --- a/fail2ban/server/action.py +++ b/fail2ban/server/action.py @@ -26,10 +26,10 @@ import threading, re from abc import ABCMeta from collections import MutableMapping -from ..helpers import getF2BLogger +from ..helpers import getLogger # Gets the instance of the logger. -logSys = getF2BLogger(__name__) +logSys = getLogger(__name__) # Create a lock for running system commands _cmd_lock = threading.Lock() @@ -136,8 +136,7 @@ class ActionBase(object): def __init__(self, jail, name): self._jail = jail self._name = name - self._logSys = logging.getLogger( - "fail2ban.%s" % self.__class__.__name__) + self._logSys = getLogger("fail2ban.%s" % self.__class__.__name__) def start(self): """Executed when the jail/action is started. diff --git a/fail2ban/server/actions.py b/fail2ban/server/actions.py index 467df510..86a47743 100644 --- a/fail2ban/server/actions.py +++ b/fail2ban/server/actions.py @@ -41,10 +41,10 @@ from .banmanager import BanManager from .jailthread import JailThread from .action import ActionBase, CommandAction, CallingMap from .mytime import MyTime -from ..helpers import getF2BLogger +from ..helpers import getLogger # Gets the instance of the logger. -logSys = getF2BLogger(__name__) +logSys = getLogger(__name__) class Actions(JailThread, Mapping): """Handles jail actions. diff --git a/fail2ban/server/asyncserver.py b/fail2ban/server/asyncserver.py index 326e35cb..14673a99 100644 --- a/fail2ban/server/asyncserver.py +++ b/fail2ban/server/asyncserver.py @@ -27,10 +27,10 @@ __license__ = "GPL" from pickle import dumps, loads, HIGHEST_PROTOCOL import asyncore, asynchat, socket, os, sys, traceback, fcntl -from ..helpers import getF2BLogger,formatExceptionInfo +from ..helpers import getLogger,formatExceptionInfo # Gets the instance of the logger. -logSys = getF2BLogger(__name__) +logSys = getLogger(__name__) if sys.version_info >= (3,): # b"" causes SyntaxError in python <= 2.5, so below implements equivalent diff --git a/fail2ban/server/banmanager.py b/fail2ban/server/banmanager.py index 68954b9c..b24fa9e5 100644 --- a/fail2ban/server/banmanager.py +++ b/fail2ban/server/banmanager.py @@ -28,10 +28,10 @@ from threading import Lock from .ticket import BanTicket from .mytime import MyTime -from ..helpers import getF2BLogger +from ..helpers import getLogger # Gets the instance of the logger. -logSys = getF2BLogger(__name__) +logSys = getLogger(__name__) ## # Banning Manager. diff --git a/fail2ban/server/database.py b/fail2ban/server/database.py index 24a3a327..51161911 100644 --- a/fail2ban/server/database.py +++ b/fail2ban/server/database.py @@ -31,10 +31,10 @@ from threading import Lock from .mytime import MyTime from .ticket import FailTicket -from ..helpers import getF2BLogger +from ..helpers import getLogger # Gets the instance of the logger. -logSys = getF2BLogger(__name__) +logSys = getLogger(__name__) if sys.version_info >= (3,): sqlite3.register_adapter( diff --git a/fail2ban/server/datedetector.py b/fail2ban/server/datedetector.py index 8d3ccaf2..fe5282fd 100644 --- a/fail2ban/server/datedetector.py +++ b/fail2ban/server/datedetector.py @@ -24,10 +24,10 @@ __license__ = "GPL" from threading import Lock from .datetemplate import DatePatternRegex, DateTai64n, DateEpoch -from ..helpers import getF2BLogger +from ..helpers import getLogger # Gets the instance of the logger. -logSys = getF2BLogger(__name__) +logSys = getLogger(__name__) class DateDetector(object): """Manages one or more date templates to find a date within a log line. diff --git a/fail2ban/server/datetemplate.py b/fail2ban/server/datetemplate.py index 0e6141e5..a5179ed1 100644 --- a/fail2ban/server/datetemplate.py +++ b/fail2ban/server/datetemplate.py @@ -28,9 +28,9 @@ import re from abc import abstractmethod from .strptime import reGroupDictStrptime, timeRE -from ..helpers import getF2BLogger +from ..helpers import getLogger -logSys = getF2BLogger(__name__) +logSys = getLogger(__name__) class DateTemplate(object): diff --git a/fail2ban/server/faildata.py b/fail2ban/server/faildata.py index 328bdb07..91aaa1ee 100644 --- a/fail2ban/server/faildata.py +++ b/fail2ban/server/faildata.py @@ -24,10 +24,10 @@ __author__ = "Cyril Jaquier" __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" -from ..helpers import getF2BLogger +from ..helpers import getLogger # Gets the instance of the logger. -logSys = getF2BLogger(__name__) +logSys = getLogger(__name__) class FailData: diff --git a/fail2ban/server/failmanager.py b/fail2ban/server/failmanager.py index 75b505c9..353f7135 100644 --- a/fail2ban/server/failmanager.py +++ b/fail2ban/server/failmanager.py @@ -29,10 +29,10 @@ import logging from .faildata import FailData from .ticket import FailTicket -from ..helpers import getF2BLogger +from ..helpers import getLogger # Gets the instance of the logger. -logSys = getF2BLogger(__name__) +logSys = getLogger(__name__) class FailManager: diff --git a/fail2ban/server/filter.py b/fail2ban/server/filter.py index ec60ed15..d1c9d2ad 100644 --- a/fail2ban/server/filter.py +++ b/fail2ban/server/filter.py @@ -31,10 +31,10 @@ from .datetemplate import DatePatternRegex, DateEpoch, DateTai64n from .mytime import MyTime from .failregex import FailRegex, Regex, RegexException from .action import CommandAction -from ..helpers import getF2BLogger +from ..helpers import getLogger # Gets the instance of the logger. -logSys = getF2BLogger(__name__) +logSys = getLogger(__name__) ## # Log reader class. diff --git a/fail2ban/server/filtergamin.py b/fail2ban/server/filtergamin.py index f6d13d5d..c9e8e31c 100644 --- a/fail2ban/server/filtergamin.py +++ b/fail2ban/server/filtergamin.py @@ -30,10 +30,10 @@ import gamin from .failmanager import FailManagerEmpty from .filter import FileFilter from .mytime import MyTime -from ..helpers import getF2BLogger +from ..helpers import getLogger # Gets the instance of the logger. -logSys = getF2BLogger(__name__) +logSys = getLogger(__name__) ## # Log reader class. diff --git a/fail2ban/server/filterpoll.py b/fail2ban/server/filterpoll.py index a94b7cb8..f37be431 100644 --- a/fail2ban/server/filterpoll.py +++ b/fail2ban/server/filterpoll.py @@ -29,10 +29,10 @@ import time, os from .failmanager import FailManagerEmpty from .filter import FileFilter from .mytime import MyTime -from ..helpers import getF2BLogger +from ..helpers import getLogger # Gets the instance of the logger. -logSys = getF2BLogger(__name__) +logSys = getLogger(__name__) ## # Log reader class. diff --git a/fail2ban/server/filterpyinotify.py b/fail2ban/server/filterpyinotify.py index 68cb9b0f..784a7e53 100644 --- a/fail2ban/server/filterpyinotify.py +++ b/fail2ban/server/filterpyinotify.py @@ -32,7 +32,7 @@ import pyinotify from .failmanager import FailManagerEmpty from .filter import FileFilter from .mytime import MyTime -from ..helpers import getF2BLogger +from ..helpers import getLogger if not hasattr(pyinotify, '__version__') \ @@ -49,7 +49,7 @@ except Exception, e: % str(e)) # Gets the instance of the logger. -logSys = getF2BLogger(__name__) +logSys = getLogger(__name__) ## # Log reader class. diff --git a/fail2ban/server/filtersystemd.py b/fail2ban/server/filtersystemd.py index 71dde126..ce89d65a 100644 --- a/fail2ban/server/filtersystemd.py +++ b/fail2ban/server/filtersystemd.py @@ -32,10 +32,10 @@ if LooseVersion(getattr(journal, '__version__', "0")) < '204': from .failmanager import FailManagerEmpty from .filter import JournalFilter from .mytime import MyTime -from ..helpers import getF2BLogger +from ..helpers import getLogger # Gets the instance of the logger. -logSys = getF2BLogger(__name__) +logSys = getLogger(__name__) ## # Journal reader class. diff --git a/fail2ban/server/jail.py b/fail2ban/server/jail.py index 5c1c4e70..e48e5d7b 100644 --- a/fail2ban/server/jail.py +++ b/fail2ban/server/jail.py @@ -26,10 +26,10 @@ __license__ = "GPL" import Queue, logging from .actions import Actions -from ..helpers import getF2BLogger +from ..helpers import getLogger # Gets the instance of the logger. -logSys = getF2BLogger(__name__) +logSys = getLogger(__name__) class Jail: """Fail2Ban jail, which manages a filter and associated actions. diff --git a/fail2ban/server/server.py b/fail2ban/server/server.py index a6be18ac..8efb2c59 100644 --- a/fail2ban/server/server.py +++ b/fail2ban/server/server.py @@ -32,10 +32,10 @@ from .filter import FileFilter, JournalFilter from .transmitter import Transmitter from .asyncserver import AsyncServer, AsyncServerException from .. import version -from ..helpers import getF2BLogger, fail2ban_excepthook +from ..helpers import getLogger, fail2ban_excepthook # Gets the instance of the logger. -logSys = getF2BLogger(__name__) +logSys = getLogger(__name__) try: from .database import Fail2BanDb @@ -339,7 +339,7 @@ class Server: def setLogLevel(self, value): try: self.__loggingLock.acquire() - logging.getLogger("fail2ban").setLevel( + getLogger("fail2ban").setLevel( getattr(logging, value.upper())) except AttributeError: raise ValueError("Invalid log level") @@ -392,7 +392,7 @@ class Server: return False # Removes previous handlers -- in reverse order since removeHandler # alter the list in-place and that can confuses the iterable - logger = logging.getLogger("fail2ban") + logger = getLogger("fail2ban") for handler in logger.handlers[::-1]: # Remove the handler. logger.removeHandler(handler) @@ -429,7 +429,7 @@ class Server: def flushLogs(self): if self.__logTarget not in ['STDERR', 'STDOUT', 'SYSLOG']: - for handler in logging.getLogger("fail2ban").handlers: + for handler in getLogger("fail2ban").handlers: try: handler.doRollover() logSys.info("rollover performed on %s" % self.__logTarget) @@ -438,7 +438,7 @@ class Server: logSys.info("flush performed on %s" % self.__logTarget) return "rolled over" else: - for handler in logging.getLogger("fail2ban").handlers: + for handler in getLogger("fail2ban").handlers: handler.flush() logSys.info("flush performed on %s" % self.__logTarget) return "flushed" diff --git a/fail2ban/server/ticket.py b/fail2ban/server/ticket.py index a216e9ed..329b3831 100644 --- a/fail2ban/server/ticket.py +++ b/fail2ban/server/ticket.py @@ -24,10 +24,10 @@ __author__ = "Cyril Jaquier" __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" -from ..helpers import getF2BLogger +from ..helpers import getLogger # Gets the instance of the logger. -logSys = getF2BLogger(__name__) +logSys = getLogger(__name__) class Ticket: diff --git a/fail2ban/server/transmitter.py b/fail2ban/server/transmitter.py index b5edf367..0cd30515 100644 --- a/fail2ban/server/transmitter.py +++ b/fail2ban/server/transmitter.py @@ -27,10 +27,10 @@ __license__ = "GPL" import time import json -from ..helpers import getF2BLogger +from ..helpers import getLogger # Gets the instance of the logger. -logSys = getF2BLogger(__name__) +logSys = getLogger(__name__) class Transmitter: diff --git a/fail2ban/tests/misctestcase.py b/fail2ban/tests/misctestcase.py index ca84eba7..64b6b65e 100644 --- a/fail2ban/tests/misctestcase.py +++ b/fail2ban/tests/misctestcase.py @@ -32,7 +32,7 @@ import datetime from glob import glob from StringIO import StringIO -from ..helpers import formatExceptionInfo, mbasename, TraceBack, FormatterWithTraceBack +from ..helpers import formatExceptionInfo, mbasename, TraceBack, FormatterWithTraceBack, getLogger from ..server.datetemplate import DatePatternRegex @@ -159,7 +159,7 @@ class TestsUtilsTest(unittest.TestCase): # and both types of traceback at once fmt = ' %(tb)s | %(tbc)s : %(message)s' - logSys = logging.getLogger("fail2ban_tests") + logSys = getLogger("fail2ban_tests") out = logging.StreamHandler(strout) out.setFormatter(Formatter(fmt)) logSys.addHandler(out) diff --git a/fail2ban/tests/servertestcase.py b/fail2ban/tests/servertestcase.py index 6ce6e54f..9b78fda8 100644 --- a/fail2ban/tests/servertestcase.py +++ b/fail2ban/tests/servertestcase.py @@ -30,14 +30,13 @@ import tempfile import os import locale import sys -import logging from ..server.failregex import Regex, FailRegex, RegexException from ..server.server import Server from ..server.jail import Jail from ..server.jailthread import JailThread from .utils import LogCaptureTestCase -from ..helpers import getF2BLogger +from ..helpers import getLogger try: from ..server import filtersystemd @@ -725,7 +724,7 @@ class TransmitterLogging(TransmitterBase): os.close(f) self.server.setLogLevel("WARNING") self.assertEqual(self.transm.proceed(["set", "logtarget", fn]), (0, fn)) - l = logging.getLogger('fail2ban') + l = getLogger('fail2ban') l.warning("Before file moved") try: f2, fn2 = tempfile.mkstemp("fail2ban.log") @@ -806,7 +805,7 @@ class _BadThread(JailThread): class LoggingTests(LogCaptureTestCase): def testGetF2BLogger(self): - testLogSys = getF2BLogger("fail2ban.some.string.with.name") + testLogSys = getLogger("fail2ban.some.string.with.name") self.assertEqual(testLogSys.parent.name, "fail2ban") self.assertEqual(testLogSys.name, "fail2ban.name") diff --git a/fail2ban/tests/utils.py b/fail2ban/tests/utils.py index f35685a4..0cb8d5b8 100644 --- a/fail2ban/tests/utils.py +++ b/fail2ban/tests/utils.py @@ -30,9 +30,9 @@ import unittest from StringIO import StringIO from ..server.mytime import MyTime -from ..helpers import getF2BLogger +from ..helpers import getLogger -logSys = getF2BLogger(__name__) +logSys = getLogger(__name__) def mtimesleep(): # no sleep now should be necessary since polling tracks now not only @@ -187,7 +187,7 @@ class LogCaptureTestCase(unittest.TestCase): # For extended testing of what gets output into logging # system, we will redirect it to a string - logSys = logging.getLogger("fail2ban") + logSys = getLogger("fail2ban") # Keep old settings self._old_level = logSys.level @@ -200,7 +200,7 @@ class LogCaptureTestCase(unittest.TestCase): def tearDown(self): """Call after every test case.""" # print "O: >>%s<<" % self._log.getvalue() - logSys = logging.getLogger("fail2ban") + logSys = getLogger("fail2ban") logSys.handlers = self._old_handlers logSys.level = self._old_level