added verbosity patch from one of my branches

debian-releases/etch
Yaroslav Halchenko 19 years ago
parent f7064d36c5
commit 1f3e33e384

1
debian/changelog vendored

@ -4,6 +4,7 @@ fail2ban (0.6.1-10) unstable; urgency=low
message
* Added configuration parameter "locale" to specify LC_TIME for time
pattern matching (closes: #367990,363391)
* Verbosity is chosen to be max between cmdline parameters and config file
-- Yaroslav Halchenko <debian@onerussian.com> Mon, 3 Jul 2006 21:59:34 -0400

@ -0,0 +1,95 @@
#! /bin/sh /usr/share/dpatch/dpatch-run
## 00_verbosity.dpatch by <debian@onerussian.com>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Verbosity can be set either from command line or from config file.
## DP: Logically the maximal verbosity from two of them should be chosen since
## DP: verbosity from cmdline can't simple increase config file verbosity
## DP: because config line might not be even read yet
@DPATCH@
diff -x '*~' -Naur fail2ban-0.6.1.pre/fail2ban.py fail2ban-0.6.1.post/fail2ban.py
--- fail2ban-0.6.1.pre/fail2ban.py 2006-03-19 00:20:44.000000000 -0500
+++ fail2ban-0.6.1.post/fail2ban.py 2006-07-03 23:29:58.000000000 -0400
@@ -161,9 +161,11 @@
"""
# enabledsections can be defined just from the command line
conf["enabledsections"] = []
+ # by default we are silent
+ cmdLineVerbose = 0
for opt in optList:
if opt[0] == "-v":
- conf["verbose"] = conf["verbose"] + 1
+ cmdLineVerbose += 1
if opt[0] == "-b":
conf["background"] = True
if opt[0] == "-d":
@@ -192,6 +194,30 @@
conf["enabledsections"] = map(lambda x: x.upper(),
re.split("[:, \t\n]", opt[1]))
+ # Let's choose the maximal verbosity from cmdLine and config
+ # files: it would better describe the intent of the user
+ conf["verbose"] = max(cmdLineVerbose, conf["verbose"])
+
+
+presetVerbosityLevel = 0
+def setVerbosityLevel(level):
+ """ Sets verbosity level if previousely set one is different
+ """
+ global presetVerbosityLevel
+ # Verbose level
+ if level != presetVerbosityLevel and level:
+ logSys.warn("Verbose level is %d"%level)
+ if level == 1:
+ logSys.setLevel(logging.INFO)
+ elif level > 1:
+ logSys.setLevel(logging.DEBUG)
+ if conf["verbose"] > 2:
+ formatterstring = ('%(levelname)s: [%(filename)s (%(lineno)d)] ' +
+ '%(message)s')
+ formatter = logging.Formatter("%(asctime)s " + formatterstring)
+ stdout.setFormatter(formatter)
+ presetVerbosityLevel = level
+
def main():
""" Fail2Ban main function
"""
@@ -220,12 +246,16 @@
# Pre-parsing of command line options for the -c option
for opt in optList:
+ if opt[0] == "-v":
+ conf["verbose"] = conf["verbose"] + 1
if opt[0] == "-c":
conf["conffile"] = opt[1]
if opt[0] in ["-h", "--help"]:
dispUsage()
if opt[0] in ["-V", "--version"]:
dispVersion()
+
+ setVerbosityLevel(conf['verbose'])
# Reads the config file and create a LogReader instance for
# each log file to check.
@@ -337,18 +367,7 @@
hdlr.setFormatter(tformatter)
logSys.addHandler(hdlr)
- # Verbose level
- if conf["verbose"]:
- logSys.warn("Verbose level is "+`conf["verbose"]`)
- if conf["verbose"] == 1:
- logSys.setLevel(logging.INFO)
- elif conf["verbose"] > 1:
- logSys.setLevel(logging.DEBUG)
- if conf["verbose"] > 2:
- formatterstring = ('%(levelname)s: [%(filename)s (%(lineno)d)] ' +
- '%(message)s')
- formatter = logging.Formatter("%(asctime)s " + formatterstring)
- stdout.setFormatter(formatter)
+ setVerbosityLevel(conf['verbose'])
# Debug mode. Should only be used by developers
if conf["debug"]:

@ -1,6 +1,7 @@
00_empty_ip
00_locale_config
00_verbosity
00_proftpd_section
00_vsftpd_regexp
01_apache2_other
02_sasl_section
00_empty_ip
00_locale_config

Loading…
Cancel
Save