mirror of https://github.com/fail2ban/fail2ban
ENH: be able to control verbosity from cmdline for fail2ban-testcases
parent
b4099dae57
commit
d0a322f2b8
|
@ -1,6 +1,8 @@
|
|||
#!/usr/bin/python
|
||||
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*-
|
||||
# vi: set ft=python sts=4 ts=4 sw=4 noet :
|
||||
"""Script to run Fail2Ban tests battery
|
||||
"""
|
||||
|
||||
# This file is part of Fail2Ban.
|
||||
#
|
||||
|
@ -19,8 +21,6 @@
|
|||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
# Author: Cyril Jaquier
|
||||
#
|
||||
# $Revision$
|
||||
|
||||
__author__ = "Cyril Jaquier"
|
||||
__version__ = "$Revision$"
|
||||
|
@ -41,6 +41,28 @@ from testcases import datedetectortestcase
|
|||
from testcases import actiontestcase
|
||||
from server.mytime import MyTime
|
||||
|
||||
from optparse import OptionParser, Option
|
||||
|
||||
def get_opt_parser():
|
||||
# use module docstring for help output
|
||||
p = OptionParser(
|
||||
usage="%s [OPTIONS]\n" % sys.argv[0] + __doc__,
|
||||
version="%prog " + version)
|
||||
|
||||
p.add_options([
|
||||
Option('-l', "--log-level", type="choice",
|
||||
dest="log_level",
|
||||
choices=('debug', 'fatal'),
|
||||
default='fatal',
|
||||
help="Log level for the logger to use during running tests"),
|
||||
])
|
||||
|
||||
return p
|
||||
|
||||
parser = get_opt_parser()
|
||||
(opts, files) = parser.parse_args()
|
||||
assert(not len(files))
|
||||
|
||||
# Set the time to a fixed, known value
|
||||
# Sun Aug 14 12:00:00 CEST 2005
|
||||
|
||||
|
@ -55,7 +77,7 @@ logSys = logging.getLogger("fail2ban")
|
|||
# Add the default logging handler
|
||||
stdout = logging.StreamHandler(sys.stdout)
|
||||
logSys.addHandler(stdout)
|
||||
logSys.setLevel(logging.FATAL)
|
||||
logSys.setLevel(getattr(logging, opts.log_level.upper()))
|
||||
|
||||
print "Fail2ban " + version + " test suite. Please wait..."
|
||||
|
||||
|
|
Loading…
Reference in New Issue