From f6f6ae81e4d445ed55de4a729a1a77b900be425a Mon Sep 17 00:00:00 2001 From: sfaulds Date: Mon, 10 Oct 2016 09:50:30 +1100 Subject: [PATCH] return error type and file info sepratly use the error type in the event action and the file and line in the event label --- resources/lib/ga_client.py | 13 ++++++++----- resources/lib/librarysync.py | 7 ++++--- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/resources/lib/ga_client.py b/resources/lib/ga_client.py index fd78e613..6a8aca13 100644 --- a/resources/lib/ga_client.py +++ b/resources/lib/ga_client.py @@ -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)) diff --git a/resources/lib/librarysync.py b/resources/lib/librarysync.py index 2f4aa455..e66cd6fb 100644 --- a/resources/lib/librarysync.py +++ b/resources/lib/librarysync.py @@ -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):