diff --git a/resources/lib/ga_client.py b/resources/lib/ga_client.py index d9a831ee..fd78e613 100644 --- a/resources/lib/ga_client.py +++ b/resources/lib/ga_client.py @@ -1,4 +1,5 @@ - +import sys +import os import requests import logging import clientinfo @@ -25,6 +26,14 @@ class GoogleAnalytics(): self.device_id = md5.new(self.device_id).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): if(settings('metricLogging') == "false"): @@ -68,5 +77,5 @@ class GoogleAnalytics(): log.error(error) if(self.testing): - log.error("GA: " + r.text.encode('utf-8')) + log.info("GA: " + r.text.encode('utf-8')) \ No newline at end of file diff --git a/resources/lib/librarysync.py b/resources/lib/librarysync.py index e85df506..2f4aa455 100644 --- a/resources/lib/librarysync.py +++ b/resources/lib/librarysync.py @@ -975,6 +975,9 @@ class LibrarySync(threading.Thread): elif "401" in e: pass except Exception as e: + ga = GoogleAnalytics() + errStr = ga.formatException() + ga.sendEventData("Exception", errStr) window('emby_dbScan', clear=True) log.exception(e) xbmcgui.Dialog().ok( @@ -982,7 +985,8 @@ class LibrarySync(threading.Thread): line1=( "Library sync thread has exited! " "You should restart Kodi now. " - "Please report this on the forum.")) + "Please report this on the forum."), + line2=(errStr)) def run_internal(self):