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: