mirror of https://github.com/fail2ban/fail2ban
ENH: fail2ban logging uses __name__ for logger names
parent
3a16ceed0a
commit
a3d82e2ab9
|
@ -109,7 +109,7 @@ else:
|
|||
|
||||
# Custom log format for the verbose tests runs
|
||||
if verbosity > 1: # pragma: no cover
|
||||
stdout.setFormatter(Formatter(' %(asctime)-15s %(thread)s' + fmt))
|
||||
stdout.setFormatter(Formatter(' %(asctime)-15s %(thread)s %(name)s' + fmt))
|
||||
else: # pragma: no cover
|
||||
# just prefix with the space
|
||||
stdout.setFormatter(Formatter(fmt))
|
||||
|
|
|
@ -31,7 +31,7 @@ import logging
|
|||
from configreader import ConfigReader
|
||||
|
||||
# Gets the instance of the logger.
|
||||
logSys = logging.getLogger("fail2ban.client.config")
|
||||
logSys = logging.getLogger(__name__)
|
||||
|
||||
class ActionReader(ConfigReader):
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ import logging
|
|||
from fail2ban.exceptions import UnknownJailException, DuplicateJailException
|
||||
|
||||
# Gets the instance of the logger.
|
||||
logSys = logging.getLogger("fail2ban.client.config")
|
||||
logSys = logging.getLogger(__name__)
|
||||
|
||||
##
|
||||
# Beautify the output of the client.
|
||||
|
|
|
@ -31,7 +31,7 @@ import logging, os
|
|||
from ConfigParser import SafeConfigParser
|
||||
|
||||
# Gets the instance of the logger.
|
||||
logSys = logging.getLogger("fail2ban.client.config")
|
||||
logSys = logging.getLogger(__name__)
|
||||
|
||||
class SafeConfigParserWithIncludes(SafeConfigParser):
|
||||
"""
|
||||
|
|
|
@ -32,7 +32,7 @@ from configparserinc import SafeConfigParserWithIncludes
|
|||
from ConfigParser import NoOptionError, NoSectionError
|
||||
|
||||
# Gets the instance of the logger.
|
||||
logSys = logging.getLogger("fail2ban.client.config")
|
||||
logSys = logging.getLogger(__name__)
|
||||
|
||||
class ConfigReader(SafeConfigParserWithIncludes):
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ from fail2banreader import Fail2banReader
|
|||
from jailsreader import JailsReader
|
||||
|
||||
# Gets the instance of the logger.
|
||||
logSys = logging.getLogger("fail2ban.client.config")
|
||||
logSys = logging.getLogger(__name__)
|
||||
|
||||
class Configurator:
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ import logging
|
|||
from configreader import ConfigReader
|
||||
|
||||
# Gets the instance of the logger.
|
||||
logSys = logging.getLogger("fail2ban.client.config")
|
||||
logSys = logging.getLogger(__name__)
|
||||
|
||||
class Fail2banReader(ConfigReader):
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ import logging
|
|||
from configreader import ConfigReader
|
||||
|
||||
# Gets the instance of the logger.
|
||||
logSys = logging.getLogger("fail2ban.client.config")
|
||||
logSys = logging.getLogger(__name__)
|
||||
|
||||
class FilterReader(ConfigReader):
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ from filterreader import FilterReader
|
|||
from actionreader import ActionReader
|
||||
|
||||
# Gets the instance of the logger.
|
||||
logSys = logging.getLogger("fail2ban.client.config")
|
||||
logSys = logging.getLogger(__name__)
|
||||
|
||||
class JailReader(ConfigReader):
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ from configreader import ConfigReader
|
|||
from jailreader import JailReader
|
||||
|
||||
# Gets the instance of the logger.
|
||||
logSys = logging.getLogger("fail2ban.client.config")
|
||||
logSys = logging.getLogger(__name__)
|
||||
|
||||
class JailsReader(ConfigReader):
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ import threading
|
|||
#from subprocess import call
|
||||
|
||||
# Gets the instance of the logger.
|
||||
logSys = logging.getLogger("fail2ban.actions.action")
|
||||
logSys = logging.getLogger(__name__)
|
||||
|
||||
# Create a lock for running system commands
|
||||
_cmd_lock = threading.Lock()
|
||||
|
|
|
@ -34,7 +34,7 @@ from mytime import MyTime
|
|||
import time, logging
|
||||
|
||||
# Gets the instance of the logger.
|
||||
logSys = logging.getLogger("fail2ban.actions")
|
||||
logSys = logging.getLogger(__name__)
|
||||
|
||||
##
|
||||
# Execute commands.
|
||||
|
|
|
@ -33,7 +33,7 @@ import asyncore, asynchat, socket, os, logging, sys, traceback
|
|||
from fail2ban import helpers
|
||||
|
||||
# Gets the instance of the logger.
|
||||
logSys = logging.getLogger("fail2ban.server")
|
||||
logSys = logging.getLogger(__name__)
|
||||
|
||||
##
|
||||
# Request handler class.
|
||||
|
|
|
@ -33,7 +33,7 @@ from mytime import MyTime
|
|||
import logging
|
||||
|
||||
# Gets the instance of the logger.
|
||||
logSys = logging.getLogger("fail2ban.action")
|
||||
logSys = logging.getLogger(__name__)
|
||||
|
||||
##
|
||||
# Banning Manager.
|
||||
|
|
|
@ -33,7 +33,7 @@ from datetemplate import DateStrptime, DateTai64n, DateEpoch, DateISO8601
|
|||
from threading import Lock
|
||||
|
||||
# Gets the instance of the logger.
|
||||
logSys = logging.getLogger("fail2ban.filter.datedetector")
|
||||
logSys = logging.getLogger(__name__)
|
||||
|
||||
class DateDetector:
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ from mytime import MyTime
|
|||
import iso8601
|
||||
|
||||
import logging
|
||||
logSys = logging.getLogger("fail2ban.datetemplate")
|
||||
logSys = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class DateTemplate:
|
||||
|
|
|
@ -30,7 +30,7 @@ __license__ = "GPL"
|
|||
import logging
|
||||
|
||||
# Gets the instance of the logger.
|
||||
logSys = logging.getLogger("fail2ban")
|
||||
logSys = logging.getLogger(__name__)
|
||||
|
||||
class FailData:
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ from threading import Lock
|
|||
import logging
|
||||
|
||||
# Gets the instance of the logger.
|
||||
logSys = logging.getLogger("fail2ban.filter")
|
||||
logSys = logging.getLogger(__name__)
|
||||
|
||||
class FailManager:
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ from failregex import FailRegex, Regex, RegexException
|
|||
import logging, re, os, fcntl, time
|
||||
|
||||
# Gets the instance of the logger.
|
||||
logSys = logging.getLogger("fail2ban.filter")
|
||||
logSys = logging.getLogger(__name__)
|
||||
|
||||
##
|
||||
# Log reader class.
|
||||
|
|
|
@ -30,7 +30,7 @@ from mytime import MyTime
|
|||
import time, logging, gamin
|
||||
|
||||
# Gets the instance of the logger.
|
||||
logSys = logging.getLogger("fail2ban.filter")
|
||||
logSys = logging.getLogger(__name__)
|
||||
|
||||
##
|
||||
# Log reader class.
|
||||
|
|
|
@ -33,7 +33,7 @@ from mytime import MyTime
|
|||
import time, logging, os
|
||||
|
||||
# Gets the instance of the logger.
|
||||
logSys = logging.getLogger("fail2ban.filter")
|
||||
logSys = logging.getLogger(__name__)
|
||||
|
||||
##
|
||||
# Log reader class.
|
||||
|
|
|
@ -38,7 +38,7 @@ if not hasattr(pyinotify, '__version__') \
|
|||
from os.path import dirname, sep as pathsep
|
||||
|
||||
# Gets the instance of the logger.
|
||||
logSys = logging.getLogger("fail2ban.filter")
|
||||
logSys = logging.getLogger(__name__)
|
||||
|
||||
##
|
||||
# Log reader class.
|
||||
|
|
|
@ -28,7 +28,7 @@ import Queue, logging
|
|||
from actions import Actions
|
||||
|
||||
# Gets the instance of the logger.
|
||||
logSys = logging.getLogger("fail2ban.jail")
|
||||
logSys = logging.getLogger(__name__)
|
||||
|
||||
class Jail:
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ from threading import Thread
|
|||
import logging
|
||||
|
||||
# Gets the instance of the logger.
|
||||
logSys = logging.getLogger("fail2ban.server")
|
||||
logSys = logging.getLogger(__name__)
|
||||
|
||||
class JailThread(Thread):
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ from fail2ban import version
|
|||
import logging, logging.handlers, sys, os, signal
|
||||
|
||||
# Gets the instance of the logger.
|
||||
logSys = logging.getLogger("fail2ban.server")
|
||||
logSys = logging.getLogger(__name__)
|
||||
|
||||
class Server:
|
||||
|
||||
|
@ -329,7 +329,7 @@ class Server:
|
|||
logLevel = logging.WARNING
|
||||
elif value == 3:
|
||||
logLevel = logging.INFO
|
||||
logging.getLogger("fail2ban").setLevel(logLevel)
|
||||
logging.getLogger(__name__).parent.parent.setLevel(logLevel)
|
||||
finally:
|
||||
self.__loggingLock.release()
|
||||
|
||||
|
@ -378,9 +378,10 @@ class Server:
|
|||
return False
|
||||
# Removes previous handlers -- in reverse order since removeHandler
|
||||
# alter the list in-place and that can confuses the iterable
|
||||
for handler in logging.getLogger("fail2ban").handlers[::-1]:
|
||||
logger = logging.getLogger(__name__).parent.parent
|
||||
for handler in logger.handlers[::-1]:
|
||||
# Remove the handler.
|
||||
logging.getLogger("fail2ban").removeHandler(handler)
|
||||
logger.removeHandler(handler)
|
||||
# And try to close -- it might be closed already
|
||||
try:
|
||||
handler.flush()
|
||||
|
@ -392,7 +393,7 @@ class Server:
|
|||
# with older Pythons -- seems to be safe to ignore there
|
||||
# tell the handler to use this format
|
||||
hdlr.setFormatter(formatter)
|
||||
logging.getLogger("fail2ban").addHandler(hdlr)
|
||||
logger.addHandler(hdlr)
|
||||
# Does not display this message at startup.
|
||||
if not self.__logTarget == None:
|
||||
logSys.info("Changed logging target to %s for Fail2ban v%s" %
|
||||
|
|
|
@ -30,7 +30,7 @@ __license__ = "GPL"
|
|||
import logging
|
||||
|
||||
# Gets the instance of the logger.
|
||||
logSys = logging.getLogger("fail2ban")
|
||||
logSys = logging.getLogger(__name__)
|
||||
|
||||
class Ticket:
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ __license__ = "GPL"
|
|||
import logging, time
|
||||
|
||||
# Gets the instance of the logger.
|
||||
logSys = logging.getLogger("fail2ban.comm")
|
||||
logSys = logging.getLogger(__name__)
|
||||
|
||||
class Transmitter:
|
||||
|
||||
|
|
Loading…
Reference in New Issue