mirror of
https://github.com/moparisthebest/SickRage
synced 2025-01-07 03:48:02 -05:00
Improved pastebin logs to search via regex and timestamps for error line then grab 50 lines of data before that.
This commit is contained in:
parent
120ea961f2
commit
477938e5f3
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
from __future__ import with_statement
|
from __future__ import with_statement
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import sys
|
import sys
|
||||||
import logging
|
import logging
|
||||||
import logging.handlers
|
import logging.handlers
|
||||||
@ -25,8 +26,7 @@ import threading
|
|||||||
import platform
|
import platform
|
||||||
|
|
||||||
import sickbeard
|
import sickbeard
|
||||||
from sickbeard import classes
|
from sickbeard import classes, encodingKludge as ek
|
||||||
from sickbeard.encodingKludge import ek
|
|
||||||
from github import Github
|
from github import Github
|
||||||
from pastebin import PastebinAPI
|
from pastebin import PastebinAPI
|
||||||
|
|
||||||
@ -147,13 +147,10 @@ class Logger(object):
|
|||||||
self.gh_issues = Github(login_or_token=sickbeard.GIT_USERNAME, password=sickbeard.GIT_PASSWORD,
|
self.gh_issues = Github(login_or_token=sickbeard.GIT_USERNAME, password=sickbeard.GIT_PASSWORD,
|
||||||
user_agent="SiCKRAGE").get_organization(gh_org).get_repo(gh_repo)
|
user_agent="SiCKRAGE").get_organization(gh_org).get_repo(gh_repo)
|
||||||
|
|
||||||
pastebin_url = None
|
|
||||||
try:
|
try:
|
||||||
if self.logFile and os.path.isfile(self.logFile):
|
if self.logFile and os.path.isfile(self.logFile):
|
||||||
with ek(open, self.logFile) as f:
|
with ek.ek(open, self.logFile) as f:
|
||||||
data = f.readlines()
|
log_data = f.readlines()
|
||||||
data = "".join(data[len(data) - 100:])
|
|
||||||
pastebin_url = PastebinAPI().paste('f59b8e9fa1fc2d033e399e6c7fb09d19', data)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -162,6 +159,19 @@ class Logger(object):
|
|||||||
if not curError.title:
|
if not curError.title:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
regex = "^(%s)\s*([A-Z]+)\s*(.+?)\s*\:\:\s*(.*)$" % curError.time
|
||||||
|
|
||||||
|
pastebin_url = None
|
||||||
|
for i, x in enumerate(reversed(log_data)):
|
||||||
|
x = ek.ss(x)
|
||||||
|
match = re.match(regex, x)
|
||||||
|
if match:
|
||||||
|
level = match.group(2)
|
||||||
|
if reverseNames[level] >= ERROR:
|
||||||
|
paste_data = "".join(log_data[len(log_data) - i - 50:])
|
||||||
|
pastebin_url = PastebinAPI().paste('f59b8e9fa1fc2d033e399e6c7fb09d19', paste_data)
|
||||||
|
break
|
||||||
|
|
||||||
message = u"### INFO\n"
|
message = u"### INFO\n"
|
||||||
message += u"Python Version: **" + sys.version[:120] + "**\n"
|
message += u"Python Version: **" + sys.version[:120] + "**\n"
|
||||||
message += u"Operating System: **" + platform.platform() + "**\n"
|
message += u"Operating System: **" + platform.platform() + "**\n"
|
||||||
|
@ -231,7 +231,8 @@ class WebHandler(BaseHandler):
|
|||||||
callback(result)
|
callback(result)
|
||||||
return result
|
return result
|
||||||
except:
|
except:
|
||||||
logger.log('Failed doing webui callback: %s' % (traceback.format_exc()), logger.DEBUG)
|
logger.log('Failed doing webui callback: %s' % (traceback.format_exc()), logger.ERROR)
|
||||||
|
raise
|
||||||
|
|
||||||
def async_done(self, results):
|
def async_done(self, results):
|
||||||
try:
|
try:
|
||||||
@ -241,6 +242,7 @@ class WebHandler(BaseHandler):
|
|||||||
logger.log('Failed sending webui reponse: %s' % (traceback.format_exc()), logger.DEBUG)
|
logger.log('Failed sending webui reponse: %s' % (traceback.format_exc()), logger.DEBUG)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
# post uses get method
|
# post uses get method
|
||||||
post = get
|
post = get
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user