mirror of https://github.com/fail2ban/fail2ban
loglevel and shortloglevel combined to single parameter loglevel, below an example logging summary with NOTICE and rest with DEBUG log-levels:
action = badips.py[... , loglevel="debug, notice"]pull/2245/head
parent
34edec297b
commit
5126068099
|
@ -32,7 +32,7 @@ else: # pragma: 3.x no cover
|
||||||
from urllib import urlencode
|
from urllib import urlencode
|
||||||
|
|
||||||
from fail2ban.server.actions import ActionBase
|
from fail2ban.server.actions import ActionBase
|
||||||
from fail2ban.helpers import str2LogLevel
|
from fail2ban.helpers import splitwords, str2LogLevel
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -75,9 +75,9 @@ class BadIPsAction(ActionBase): # pragma: no cover - may be unavailable
|
||||||
loglevel : int/str, optional
|
loglevel : int/str, optional
|
||||||
Log level of the message when an IP is (un)banned.
|
Log level of the message when an IP is (un)banned.
|
||||||
Default `DEBUG`.
|
Default `DEBUG`.
|
||||||
shortloglevel : int/str, optional
|
Can be also supplied as two-value list (comma- or space separated) to
|
||||||
Log level of the summary message when a group of IPs is (un)banned.
|
provide level of the summary message when a group of IPs is (un)banned.
|
||||||
Default `DEBUG`.
|
Example `DEBUG,INFO`.
|
||||||
agent : str, optional
|
agent : str, optional
|
||||||
User agent transmitted to server.
|
User agent transmitted to server.
|
||||||
Default `Fail2Ban/ver.`
|
Default `Fail2Ban/ver.`
|
||||||
|
@ -95,7 +95,7 @@ class BadIPsAction(ActionBase): # pragma: no cover - may be unavailable
|
||||||
|
|
||||||
def __init__(self, jail, name, category, score=3, age="24h", key=None,
|
def __init__(self, jail, name, category, score=3, age="24h", key=None,
|
||||||
banaction=None, bancategory=None, bankey=None, updateperiod=900,
|
banaction=None, bancategory=None, bankey=None, updateperiod=900,
|
||||||
loglevel='DEBUG', shortloglevel='DEBUG', agent="Fail2Ban", timeout=TIMEOUT):
|
loglevel='DEBUG', agent="Fail2Ban", timeout=TIMEOUT):
|
||||||
super(BadIPsAction, self).__init__(jail, name)
|
super(BadIPsAction, self).__init__(jail, name)
|
||||||
|
|
||||||
self.timeout = timeout
|
self.timeout = timeout
|
||||||
|
@ -107,8 +107,9 @@ class BadIPsAction(ActionBase): # pragma: no cover - may be unavailable
|
||||||
self.banaction = banaction
|
self.banaction = banaction
|
||||||
self.bancategory = bancategory or category
|
self.bancategory = bancategory or category
|
||||||
self.bankey = bankey
|
self.bankey = bankey
|
||||||
self.loglevel = str2LogLevel(loglevel)
|
loglevel = splitwords(loglevel)
|
||||||
self.shortloglevel = str2LogLevel(shortloglevel)
|
self.sumloglevel = str2LogLevel(loglevel[-1])
|
||||||
|
self.loglevel = str2LogLevel(loglevel[0])
|
||||||
self.updateperiod = updateperiod
|
self.updateperiod = updateperiod
|
||||||
|
|
||||||
self._bannedips = set()
|
self._bannedips = set()
|
||||||
|
@ -355,7 +356,7 @@ class BadIPsAction(ActionBase): # pragma: no cover - may be unavailable
|
||||||
p = len(s)
|
p = len(s)
|
||||||
self._banIPs(s)
|
self._banIPs(s)
|
||||||
if m != 0 or p != 0:
|
if m != 0 or p != 0:
|
||||||
self._logSys.log(self.shortloglevel,
|
self._logSys.log(self.sumloglevel,
|
||||||
"Updated IPs for jail '%s' (-%d/+%d)",
|
"Updated IPs for jail '%s' (-%d/+%d)",
|
||||||
self._jail.name, m, p)
|
self._jail.name, m, p)
|
||||||
self._logSys.debug(
|
self._logSys.debug(
|
||||||
|
|
Loading…
Reference in New Issue