return error type and file info sepratly

use the error type in the event action and the file and line in the event label
This commit is contained in:
sfaulds 2016-10-10 09:50:30 +11:00
parent fb0ae730a0
commit f6f6ae81e4
2 changed files with 12 additions and 8 deletions

View file

@ -29,12 +29,13 @@ class GoogleAnalytics():
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__)
errorFile = "%s:%s" % (fname, exc_tb.tb_lineno)
errorType = "%s" % (exc_type.__name__)
del(exc_type, exc_obj, exc_tb)
log.error(errorMessage)
return errorMessage
log.error(errorType + " - " + errorFile)
return errorType, errorFile
def sendEventData(self, eventCategory, eventAction):
def sendEventData(self, eventCategory, eventAction, eventLabel=None):
if(settings('metricLogging') == "false"):
return
@ -62,7 +63,9 @@ class GoogleAnalytics():
data['t'] = 'event' # action type
data['ec'] = eventCategory # Event Category
data['ea'] = eventAction # Event Action
#data['el'] = 'Play' # Event Label
if(eventLabel != None):
data['el'] = eventLabel # Event Label
log.info("GA: " + str(data))

View file

@ -968,6 +968,7 @@ class LibrarySync(threading.Thread):
def run(self):
try:
val = 1/0
self.run_internal()
except Warning as e:
if "restricted" in e:
@ -976,8 +977,8 @@ class LibrarySync(threading.Thread):
pass
except Exception as e:
ga = GoogleAnalytics()
errStr = ga.formatException()
ga.sendEventData("Exception", errStr)
errStrings = ga.formatException()
ga.sendEventData("Exception", errStrings[0], errStrings[1])
window('emby_dbScan', clear=True)
log.exception(e)
xbmcgui.Dialog().ok(
@ -986,7 +987,7 @@ class LibrarySync(threading.Thread):
"Library sync thread has exited! "
"You should restart Kodi now. "
"Please report this on the forum."),
line2=(errStr))
line2=(errStrings[0] + " (" + errStrings[1] + ")"))
def run_internal(self):