filter.py: repair start-time of initial seek to time (regardless the position of `findtime` option in config);

jailreader.py: additionally relocate the option `logpath` after all log-related data (backend, date-pattern, etc) that may be needed by the first usage (gh-2173).
Thanks to Matt Stancliff (mattsta)
pull/2173/head
sebres 2018-07-06 17:04:10 +02:00
parent 00a0e98041
commit 1eb93e2556
2 changed files with 18 additions and 18 deletions

View File

@ -93,9 +93,6 @@ class JailReader(ConfigReader):
["string", "backend", "auto"], ["string", "backend", "auto"],
["int", "maxretry", None], ["int", "maxretry", None],
["string", "findtime", None], ["string", "findtime", None],
["string", "logpath", None],
["string", "logtimezone", None],
["string", "logencoding", None],
["string", "bantime", None], ["string", "bantime", None],
["string", "usedns", None], # be sure usedns is before all regex(s) in stream ["string", "usedns", None], # be sure usedns is before all regex(s) in stream
["string", "failregex", None], ["string", "failregex", None],
@ -105,6 +102,9 @@ class JailReader(ConfigReader):
["string", "ignoreip", None], ["string", "ignoreip", None],
["string", "filter", ""], ["string", "filter", ""],
["string", "datepattern", None], ["string", "datepattern", None],
["string", "logtimezone", None],
["string", "logencoding", None],
["string", "logpath", None], # logpath after all log-related data (backend, date-pattern, etc)
["string", "action", ""]] ["string", "action", ""]]
# Before interpolation (substitution) add static options always available as default: # Before interpolation (substitution) add static options always available as default:

View File

@ -887,9 +887,6 @@ class FileFilter(Filter):
self.__logs[path] = log self.__logs[path] = log
logSys.info("Added logfile: %r (pos = %s, hash = %s)" , path, log.getPos(), log.getHash()) logSys.info("Added logfile: %r (pos = %s, hash = %s)" , path, log.getPos(), log.getHash())
if autoSeek: if autoSeek:
# if default, seek to "current time" - "find time":
if isinstance(autoSeek, bool):
autoSeek = MyTime.time() - self.getFindTime()
self.__autoSeek[path] = autoSeek self.__autoSeek[path] = autoSeek
self._addLogPath(path) # backend specific self._addLogPath(path) # backend specific
@ -999,18 +996,21 @@ class FileFilter(Filter):
return False return False
# seek to find time for first usage only (prevent performance decline with polling of big files) # seek to find time for first usage only (prevent performance decline with polling of big files)
if self.__autoSeek.get(filename): if self.__autoSeek:
startTime = self.__autoSeek[filename] startTime = self.__autoSeek.pop(filename, None)
del self.__autoSeek[filename] if startTime:
# prevent completely read of big files first time (after start of service), # if default, seek to "current time" - "find time":
# initial seek to start time using half-interval search algorithm: if isinstance(startTime, bool):
try: startTime = MyTime.time() - self.getFindTime()
self.seekToTime(log, startTime) # prevent completely read of big files first time (after start of service),
except Exception as e: # pragma: no cover # initial seek to start time using half-interval search algorithm:
logSys.error("Error during seek to start time in \"%s\"", filename) try:
raise self.seekToTime(log, startTime)
logSys.exception(e) except Exception as e: # pragma: no cover
return False logSys.error("Error during seek to start time in \"%s\"", filename)
raise
logSys.exception(e)
return False
if has_content: if has_content:
while not self.idle: while not self.idle: