From a2ea1164b3ed987c8ef9e30874a1c7e4adf079bc Mon Sep 17 00:00:00 2001 From: Cyril Jaquier Date: Mon, 11 Oct 2004 10:23:53 +0000 Subject: [PATCH] - Add log4py support - Remove old verbose mode git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/trunk@18 a942ae1a-1317-0410-a47c-b1dcaea8d605 --- logreader/logreader.py | 11 +++++------ logreader/metalog.py | 6 ++---- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/logreader/logreader.py b/logreader/logreader.py index f17711f8..9c134307 100644 --- a/logreader/logreader.py +++ b/logreader/logreader.py @@ -28,12 +28,12 @@ import os, sys class LogReader: - def __init__(self, logPath, findTime = 3600, verbose = False): + def __init__(self, logPath, logSys, findTime = 3600): self.logPath = logPath self.findTime = findTime self.ignoreIpList = [] self.lastModTime = 0 - self.verbose = verbose + self.logSys = logSys def addIgnoreIP(self, ip): self.ignoreIpList.append(ip) @@ -45,7 +45,7 @@ class LogReader: try: fileHandler = open(self.logPath) except OSError: - print "Unable to open", self.logPath + self.logSys.error("Unable to open "+self.logPath) sys.exit(-1) return fileHandler @@ -53,14 +53,13 @@ class LogReader: try: logStats = os.stat(self.logPath) except OSError: - print "Unable to get stat on", logPath + self.logSys.error("Unable to get stat on "+self.logPath) sys.exit(-1) if self.lastModTime == logStats.st_mtime: return False else: - if self.verbose: - print self.logPath, 'has been modified' + self.logSys.debug(self.logPath+" has been modified") self.lastModTime = logStats.st_mtime return True diff --git a/logreader/metalog.py b/logreader/metalog.py index c8e3db12..31b4d564 100644 --- a/logreader/metalog.py +++ b/logreader/metalog.py @@ -41,11 +41,9 @@ class Metalog(LogReader): if unixTime < time.time()-self.findTime: continue if self.inIgnoreIPList(ip): - if self.verbose: - print 'Ignore', ip + self.logSys.debug("Ignore "+ip) continue - if self.verbose: - print 'Found', ip, 'at', unixTime + self.logSys.debug("Found "+ip) if ipList.has_key(ip): ipList[ip] = (ipList[ip][0]+1, unixTime) else: