mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-10 04:06:11 +00:00
add wrapper fun for logging errors
This commit is contained in:
parent
1554a52bf7
commit
e34734931d
5 changed files with 31 additions and 3 deletions
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<addon id="plugin.video.emby"
|
||||
name="Emby"
|
||||
version="2.3.4"
|
||||
version="2.3.5"
|
||||
provider-name="Emby.media">
|
||||
<requires>
|
||||
<import addon="xbmc.python" version="2.19.0"/>
|
||||
|
|
|
@ -9,7 +9,7 @@ import xbmc
|
|||
import platform
|
||||
import xbmcgui
|
||||
import time
|
||||
from utils import window, settings, language as lang
|
||||
from utils import settings, language as lang
|
||||
|
||||
log = logging.getLogger("EMBY."+__name__)
|
||||
|
||||
|
@ -18,6 +18,24 @@ log = logging.getLogger("EMBY."+__name__)
|
|||
|
||||
logEventHistory = {}
|
||||
|
||||
# wrap a function to catch, log and then re throw an exception
|
||||
def log_error(errors=(Exception, )):
|
||||
def decorator(func):
|
||||
def wrapper(*args, **kwargs):
|
||||
try:
|
||||
return func(*args, **kwargs)
|
||||
except errors as error:
|
||||
ga = GoogleAnalytics()
|
||||
errStrings = ga.formatException()
|
||||
ga.sendEventData("Exception", errStrings[0], errStrings[1], True)
|
||||
log.exception(error)
|
||||
log.error("log_error: %s \n args: %s \n kwargs: %s",
|
||||
func.__name__, args, kwargs)
|
||||
raise
|
||||
return wrapper
|
||||
return decorator
|
||||
|
||||
# main GA class
|
||||
class GoogleAnalytics():
|
||||
|
||||
testing = False
|
||||
|
|
|
@ -12,6 +12,7 @@ import downloadutils
|
|||
import embydb_functions as embydb
|
||||
import playbackutils as pbutils
|
||||
from utils import window, settings, kodiSQL
|
||||
from ga_client import log_error
|
||||
|
||||
#################################################################################################
|
||||
|
||||
|
@ -56,6 +57,7 @@ class KodiMonitor(xbmc.Monitor):
|
|||
log.info("New context setting: %s", current_context)
|
||||
window('emby_context', value=current_context)
|
||||
|
||||
@log_error()
|
||||
def onNotification(self, sender, method, data):
|
||||
|
||||
if method not in ('Playlist.OnAdd', 'Player.OnStop', 'Player.OnClear'):
|
||||
|
|
|
@ -14,7 +14,7 @@ import downloadutils
|
|||
import kodidb_functions as kodidb
|
||||
import websocket_client as wsc
|
||||
from utils import window, settings, language as lang
|
||||
from ga_client import GoogleAnalytics
|
||||
from ga_client import GoogleAnalytics, log_error
|
||||
|
||||
#################################################################################################
|
||||
|
||||
|
@ -44,6 +44,7 @@ class Player(xbmc.Player):
|
|||
log.debug("Starting playback monitor.")
|
||||
xbmc.Player.__init__(self)
|
||||
|
||||
@log_error()
|
||||
def onPlayBackStarted(self):
|
||||
# Will be called when xbmc starts playing a file
|
||||
self.stopAll()
|
||||
|
@ -356,6 +357,7 @@ class Player(xbmc.Player):
|
|||
log.debug("Report: %s" % postdata)
|
||||
self.ws.send_progress_update(postdata)
|
||||
|
||||
@log_error()
|
||||
def onPlayBackPaused(self):
|
||||
|
||||
currentFile = self.currentFile
|
||||
|
@ -366,6 +368,7 @@ class Player(xbmc.Player):
|
|||
|
||||
self.reportPlayback()
|
||||
|
||||
@log_error()
|
||||
def onPlayBackResumed(self):
|
||||
|
||||
currentFile = self.currentFile
|
||||
|
@ -376,6 +379,7 @@ class Player(xbmc.Player):
|
|||
|
||||
self.reportPlayback()
|
||||
|
||||
@log_error()
|
||||
def onPlayBackSeek(self, time, seekOffset):
|
||||
# Make position when seeking a bit more accurate
|
||||
currentFile = self.currentFile
|
||||
|
@ -387,6 +391,7 @@ class Player(xbmc.Player):
|
|||
|
||||
self.reportPlayback()
|
||||
|
||||
@log_error()
|
||||
def onPlayBackStopped(self):
|
||||
# Will be called when user stops xbmc playing a file
|
||||
log.debug("ONPLAYBACK_STOPPED")
|
||||
|
@ -396,6 +401,7 @@ class Player(xbmc.Player):
|
|||
log.info("Clear playlist properties.")
|
||||
self.stopAll()
|
||||
|
||||
@log_error()
|
||||
def onPlayBackEnded(self):
|
||||
# Will be called when xbmc stops playing a file
|
||||
log.debug("ONPLAYBACK_ENDED")
|
||||
|
|
|
@ -15,6 +15,7 @@ import librarysync
|
|||
import playlist
|
||||
import userclient
|
||||
from utils import window, settings, dialog, language as lang, JSONRPC
|
||||
from ga_client import log_error
|
||||
|
||||
##################################################################################################
|
||||
|
||||
|
@ -60,6 +61,7 @@ class WebSocketClient(threading.Thread):
|
|||
except Exception as error:
|
||||
log.exception(error)
|
||||
|
||||
@log_error()
|
||||
def on_message(self, ws, message):
|
||||
|
||||
result = json.loads(message)
|
||||
|
|
Loading…
Reference in a new issue