From 5999e76925c48bf9a46676e1b3591c3e04b77cc8 Mon Sep 17 00:00:00 2001 From: fernandog Date: Wed, 18 Feb 2015 21:03:09 -0200 Subject: [PATCH] New Feature - Log search and log filter by SR thread --- gui/slick/interfaces/default/viewlogs.tmpl | 63 ++++++++++++++++++---- sickbeard/webserve.py | 33 +++++++++++- 2 files changed, 84 insertions(+), 12 deletions(-) diff --git a/gui/slick/interfaces/default/viewlogs.tmpl b/gui/slick/interfaces/default/viewlogs.tmpl index 9ef73ebe..6abb1209 100644 --- a/gui/slick/interfaces/default/viewlogs.tmpl +++ b/gui/slick/interfaces/default/viewlogs.tmpl @@ -13,10 +13,51 @@ - - -#include $os.path.join($sickbeard.PROG_DIR,"gui/slick/interfaces/default/inc_bottom.tmpl") +#include $os.path.join($sickbeard.PROG_DIR,"gui/slick/interfaces/default/inc_bottom.tmpl") \ No newline at end of file diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index 94d155f0..9bfa8a86 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -4732,13 +4732,35 @@ class ErrorLogs(WebRoot): classes.ErrorViewer.clear() return self.redirect("/errorlogs/") - def viewlog(self, minLevel=logger.INFO, maxLines=500): + def viewlog(self, minLevel=logger.INFO, logFilter="",logSearch=None, maxLines=500): t = PageTemplate(rh=self, file="viewlogs.tmpl") t.submenu = self.ErrorLogsMenu() minLevel = int(minLevel) + logNameFilters = {'': u'<No Filter>', + 'DAILYSEARCHER': u'Daily Searcher', + 'BACKLOG': u'Backlog', + 'SHOWUPDATER': u'Show Updater', + 'CHECKVERSION': u'Check Version', + 'SHOWQUEUE': u'Show Queue', + 'SEARCHQUEUE': u'Search Queue', + 'FINDPROPERS': u'Find Propers', + 'POSTPROCESSER': u'Postprocesser', + 'FINDSUBTITLES': u'Find Subtitles', + 'TRAKTCHECKER': u'Trakt Checker', + 'EVENT': u'Event', + 'ERROR': u'Error', + 'TORNADO': u'Tornado', + 'Thread': u'Thread', + 'MAIN': u'Main' + } + + if logFilter not in logNameFilters: + logFilter = '' + + data = [] if os.path.isfile(logger.logFile): with ek.ek(open, logger.logFile) as f: @@ -4759,11 +4781,15 @@ class ErrorLogs(WebRoot): if match: level = match.group(7) + logName = match.group(8) if level not in logger.reverseNames: lastLine = False continue - if logger.reverseNames[level] >= minLevel: + if logSearch and logSearch.lower() in x.lower(): + lastLine = True + finalData.append(x) + elif not logSearch and logger.reverseNames[level] >= minLevel and (logFilter == '' or logName.startswith(logFilter)): lastLine = True finalData.append(x) else: @@ -4782,6 +4808,9 @@ class ErrorLogs(WebRoot): t.logLines = result t.minLevel = minLevel + t.logNameFilters = logNameFilters + t.logFilter = logFilter + t.logSearch = logSearch return t.respond()