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