add exception string to an event

log sync failed events
This commit is contained in:
sfaulds 2016-10-10 09:05:51 +11:00
parent 6b446ff1a1
commit fb0ae730a0
2 changed files with 16 additions and 3 deletions

View File

@ -1,4 +1,5 @@
import sys
import os
import requests import requests
import logging import logging
import clientinfo import clientinfo
@ -25,6 +26,14 @@ class GoogleAnalytics():
self.device_id = md5.new(self.device_id).hexdigest() self.device_id = md5.new(self.device_id).hexdigest()
self.user_name = md5.new(self.user_name).hexdigest() self.user_name = md5.new(self.user_name).hexdigest()
def formatException(self):
exc_type, exc_obj, exc_tb = sys.exc_info()
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
errorMessage = "%s:%s-%s" % (fname, exc_tb.tb_lineno, exc_type.__name__)
del(exc_type, exc_obj, exc_tb)
log.error(errorMessage)
return errorMessage
def sendEventData(self, eventCategory, eventAction): def sendEventData(self, eventCategory, eventAction):
if(settings('metricLogging') == "false"): if(settings('metricLogging') == "false"):
@ -68,5 +77,5 @@ class GoogleAnalytics():
log.error(error) log.error(error)
if(self.testing): if(self.testing):
log.error("GA: " + r.text.encode('utf-8')) log.info("GA: " + r.text.encode('utf-8'))

View File

@ -975,6 +975,9 @@ class LibrarySync(threading.Thread):
elif "401" in e: elif "401" in e:
pass pass
except Exception as e: except Exception as e:
ga = GoogleAnalytics()
errStr = ga.formatException()
ga.sendEventData("Exception", errStr)
window('emby_dbScan', clear=True) window('emby_dbScan', clear=True)
log.exception(e) log.exception(e)
xbmcgui.Dialog().ok( xbmcgui.Dialog().ok(
@ -982,7 +985,8 @@ class LibrarySync(threading.Thread):
line1=( line1=(
"Library sync thread has exited! " "Library sync thread has exited! "
"You should restart Kodi now. " "You should restart Kodi now. "
"Please report this on the forum.")) "Please report this on the forum."),
line2=(errStr))
def run_internal(self): def run_internal(self):