ENH: more of heavydebug'ing for FilterPoll

pull/280/head
Yaroslav Halchenko 12 years ago
parent e9c8a51ce4
commit 2ffc143597

@ -30,6 +30,11 @@ from mytime import MyTime
import time, logging, os import time, logging, os
def _ctime(t):
"""Given time in seconds provide string representation with milliseconds
"""
return "%s%.3f" %(time.strftime("%X", time.localtime(t)), (t-int(t)))
# Gets the instance of the logger. # Gets the instance of the logger.
logSys = logging.getLogger("fail2ban.filter") logSys = logging.getLogger("fail2ban.filter")
@ -84,6 +89,9 @@ class FilterPoll(FileFilter):
def run(self): def run(self):
self.setActive(True) self.setActive(True)
while self._isActive(): while self._isActive():
if logSys.getEffectiveLevel() <= 6:
logSys.log(6, "Woke up idle=%s with %d files monitored",
self.getIdle(), len(self.getLogPath()))
if not self.getIdle(): if not self.getIdle():
# Get file modification # Get file modification
for container in self.getLogPath(): for container in self.getLogPath():
@ -119,6 +127,12 @@ class FilterPoll(FileFilter):
try: try:
logStats = os.stat(filename) logStats = os.stat(filename)
self.__file404Cnt[filename] = 0 self.__file404Cnt[filename] = 0
if logSys.getEffectiveLevel() <= 7:
# we do not want to waste time on strftime etc if not necessary
dt = logStats.st_mtime - self.__lastModTime[filename]
logSys.log(7, "Checking %s for being modified. Previous/current mtimes: %s / %s. dt: %s",
filename, _ctime(self.__lastModTime[filename]), _ctime(logStats.st_mtime), dt)
# os.system("stat %s | grep Modify" % filename)
if self.__lastModTime[filename] == logStats.st_mtime: if self.__lastModTime[filename] == logStats.st_mtime:
return False return False
else: else:

Loading…
Cancel
Save