mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2025-01-24 17:06:11 +00:00
Merge pull request #277 from oddstr13/pr-logging-2
Attempt to improve logging
This commit is contained in:
commit
87af711c94
55 changed files with 159 additions and 184 deletions
|
@ -3,7 +3,6 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
|
||||
#################################################################################################
|
||||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
@ -19,10 +18,11 @@ sys.path.insert(0, __base__)
|
|||
#################################################################################################
|
||||
|
||||
from entrypoint import Context # noqa: F402
|
||||
from helper import LazyLogger # noqa: F402
|
||||
|
||||
#################################################################################################
|
||||
|
||||
LOG = logging.getLogger("JELLYFIN.context")
|
||||
LOG = LazyLogger(__name__)
|
||||
|
||||
#################################################################################################
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
|
||||
#################################################################################################
|
||||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
@ -19,10 +18,11 @@ sys.path.insert(0, __base__)
|
|||
#################################################################################################
|
||||
|
||||
from entrypoint import Context # noqa: F402
|
||||
from helper import LazyLogger # noqa: F402
|
||||
|
||||
#################################################################################################
|
||||
|
||||
LOG = logging.getLogger("JELLYFIN.context")
|
||||
LOG = LazyLogger(__name__)
|
||||
|
||||
#################################################################################################
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
|
||||
#################################################################################################
|
||||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
@ -19,10 +18,11 @@ sys.path.insert(0, __base__)
|
|||
#################################################################################################
|
||||
|
||||
from entrypoint import Events # noqa: F402
|
||||
from helper import LazyLogger # noqa: F402
|
||||
|
||||
#################################################################################################
|
||||
|
||||
LOG = logging.getLogger("JELLYFIN.default")
|
||||
LOG = LazyLogger(__name__)
|
||||
|
||||
#################################################################################################
|
||||
|
||||
|
|
|
@ -3,17 +3,17 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
|
||||
#################################################################################################
|
||||
|
||||
import logging
|
||||
import os
|
||||
|
||||
from kodi_six import xbmc, xbmcaddon, xbmcvfs
|
||||
|
||||
from helper import translate, window, settings, addon_id, dialog
|
||||
from helper.utils import create_id
|
||||
from helper import LazyLogger # noqa: F402
|
||||
|
||||
##################################################################################################
|
||||
|
||||
LOG = logging.getLogger("JELLYFIN." + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
|
||||
##################################################################################################
|
||||
|
||||
|
|
|
@ -3,8 +3,6 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
|
||||
##################################################################################################
|
||||
|
||||
import logging
|
||||
|
||||
from kodi_six import xbmc, xbmcaddon
|
||||
|
||||
import client
|
||||
|
@ -14,10 +12,11 @@ from helper import settings, addon_id, event, api, window
|
|||
from jellyfin import Jellyfin
|
||||
from jellyfin.connection_manager import CONNECTION_STATE
|
||||
from jellyfin.exceptions import HTTPException
|
||||
from helper import LazyLogger
|
||||
|
||||
##################################################################################################
|
||||
|
||||
LOG = logging.getLogger("JELLYFIN." + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
XML_PATH = (xbmcaddon.Addon(addon_id()).getAddonInfo('path'), "default", "1080i")
|
||||
|
||||
##################################################################################################
|
||||
|
|
|
@ -14,10 +14,11 @@ from six import text_type
|
|||
from database import jellyfin_db
|
||||
from helper import translate, settings, window, dialog
|
||||
from objects import obj
|
||||
from helper import LazyLogger
|
||||
|
||||
#################################################################################################
|
||||
|
||||
LOG = logging.getLogger("JELLYFIN." + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
|
||||
#################################################################################################
|
||||
|
||||
|
|
|
@ -2,13 +2,12 @@
|
|||
from __future__ import division, absolute_import, print_function, unicode_literals
|
||||
#################################################################################################
|
||||
|
||||
import logging
|
||||
|
||||
from database import queries as QU
|
||||
from helper import LazyLogger
|
||||
|
||||
##################################################################################################
|
||||
|
||||
LOG = logging.getLogger("JELLYFIN." + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
|
||||
##################################################################################################
|
||||
|
||||
|
|
|
@ -3,17 +3,17 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
|
||||
##################################################################################################
|
||||
|
||||
import logging
|
||||
import os
|
||||
|
||||
from kodi_six import xbmcgui, xbmcaddon
|
||||
from six import ensure_text
|
||||
|
||||
from helper import window, addon_id
|
||||
from helper import LazyLogger
|
||||
|
||||
##################################################################################################
|
||||
|
||||
LOG = logging.getLogger("JELLYFIN." + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
ACTION_PARENT_DIR = 9
|
||||
ACTION_PREVIOUS_MENU = 10
|
||||
ACTION_BACK = 92
|
||||
|
|
|
@ -3,17 +3,17 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
|
||||
##################################################################################################
|
||||
|
||||
import logging
|
||||
import os
|
||||
|
||||
from six import iteritems
|
||||
from kodi_six import xbmcgui, xbmcaddon
|
||||
|
||||
from helper import translate, addon_id
|
||||
from helper import LazyLogger
|
||||
|
||||
##################################################################################################
|
||||
|
||||
LOG = logging.getLogger("JELLYFIN." + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
ACTION_PARENT_DIR = 9
|
||||
ACTION_PREVIOUS_MENU = 10
|
||||
ACTION_BACK = 92
|
||||
|
|
|
@ -3,13 +3,13 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
|
||||
##################################################################################################
|
||||
|
||||
import logging
|
||||
|
||||
from kodi_six import xbmc, xbmcgui
|
||||
|
||||
from helper import LazyLogger
|
||||
|
||||
##################################################################################################
|
||||
|
||||
LOG = logging.getLogger("JELLYFIN." + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
ACTION_PARENT_DIR = 9
|
||||
ACTION_PREVIOUS_MENU = 10
|
||||
ACTION_BACK = 92
|
||||
|
|
|
@ -3,17 +3,16 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
|
||||
##################################################################################################
|
||||
|
||||
import logging
|
||||
|
||||
from six import iteritems
|
||||
from kodi_six import xbmc, xbmcgui
|
||||
|
||||
from helper import translate
|
||||
from jellyfin.connection_manager import CONNECTION_STATE
|
||||
from helper import LazyLogger
|
||||
|
||||
##################################################################################################
|
||||
|
||||
LOG = logging.getLogger("JELLYFIN." + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
ACTION_PARENT_DIR = 9
|
||||
ACTION_PREVIOUS_MENU = 10
|
||||
ACTION_BACK = 92
|
||||
|
|
|
@ -3,7 +3,6 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
|
||||
##################################################################################################
|
||||
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
|
||||
|
@ -12,10 +11,11 @@ from kodi_six import xbmcgui, xbmcaddon
|
|||
|
||||
from helper import translate, addon_id
|
||||
from jellyfin.connection_manager import CONNECTION_STATE
|
||||
from helper import LazyLogger
|
||||
|
||||
##################################################################################################
|
||||
|
||||
LOG = logging.getLogger("JELLYFIN." + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
ACTION_PARENT_DIR = 9
|
||||
ACTION_PREVIOUS_MENU = 10
|
||||
ACTION_BACK = 92
|
||||
|
|
|
@ -3,14 +3,14 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
|
||||
##################################################################################################
|
||||
|
||||
import logging
|
||||
|
||||
from six import iteritems
|
||||
from kodi_six import xbmc, xbmcgui
|
||||
|
||||
from helper import LazyLogger
|
||||
|
||||
##################################################################################################
|
||||
|
||||
LOG = logging.getLogger("JELLYFIN." + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
ACTION_PARENT_DIR = 9
|
||||
ACTION_PREVIOUS_MENU = 10
|
||||
ACTION_BACK = 92
|
||||
|
|
|
@ -3,7 +3,6 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
|
||||
#################################################################################################
|
||||
|
||||
import logging
|
||||
import threading
|
||||
import concurrent.futures
|
||||
from datetime import date
|
||||
|
@ -16,10 +15,11 @@ from helper import settings, stop, event, window, create_id
|
|||
from jellyfin import Jellyfin
|
||||
from jellyfin import api
|
||||
from jellyfin.exceptions import HTTPException
|
||||
from helper import LazyLogger
|
||||
|
||||
#################################################################################################
|
||||
|
||||
LOG = logging.getLogger("JELLYFIN." + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
LIMIT = min(int(settings('limitIndex') or 50), 50)
|
||||
DTHREADS = int(settings('limitThreads') or 3)
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import logging
|
|||
|
||||
from kodi_six import xbmc, xbmcvfs
|
||||
|
||||
from helper import loghandler
|
||||
from helper import LazyLogger
|
||||
from jellyfin import Jellyfin
|
||||
|
||||
from .default import Events
|
||||
|
@ -16,9 +16,6 @@ from .context import Context
|
|||
|
||||
#################################################################################################
|
||||
|
||||
Jellyfin.set_loghandler(loghandler.LogHandler, logging.DEBUG)
|
||||
loghandler.reset()
|
||||
loghandler.config()
|
||||
LOG = logging.getLogger('JELLYFIN.entrypoint')
|
||||
LOG = LazyLogger(__name__)
|
||||
|
||||
#################################################################################################
|
||||
|
|
|
@ -4,7 +4,6 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
#################################################################################################
|
||||
|
||||
import json
|
||||
import logging
|
||||
import sys
|
||||
|
||||
from kodi_six import xbmc, xbmcaddon
|
||||
|
@ -13,10 +12,11 @@ import database
|
|||
from dialogs import context
|
||||
from helper import translate, settings, dialog
|
||||
from downloader import TheVoid
|
||||
from helper import LazyLogger
|
||||
|
||||
#################################################################################################
|
||||
|
||||
LOG = logging.getLogger("JELLYFIN." + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
XML_PATH = (xbmcaddon.Addon('plugin.video.jellyfin').getAddonInfo('path'), "default", "1080i")
|
||||
OPTIONS = {
|
||||
'Refresh': translate(30410),
|
||||
|
|
|
@ -3,7 +3,6 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
|
||||
#################################################################################################
|
||||
|
||||
import logging
|
||||
import sys
|
||||
import os
|
||||
|
||||
|
@ -17,10 +16,11 @@ from objects import Objects, Actions
|
|||
from downloader import TheVoid
|
||||
from helper import translate, event, settings, window, dialog, api, JSONRPC
|
||||
from helper.utils import JsonDebugPrinter
|
||||
from helper import LazyLogger
|
||||
|
||||
#################################################################################################
|
||||
|
||||
LOG = logging.getLogger("JELLYFIN." + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
|
||||
#################################################################################################
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
#################################################################################################
|
||||
|
||||
import json
|
||||
import logging
|
||||
import sys
|
||||
from datetime import datetime
|
||||
|
||||
|
@ -22,10 +21,11 @@ from views import Views, verify_kodi_defaults
|
|||
from helper import translate, window, settings, event, dialog, set_addon_mode
|
||||
from helper.utils import JsonDebugPrinter
|
||||
from jellyfin import Jellyfin
|
||||
from helper import LazyLogger
|
||||
|
||||
#################################################################################################
|
||||
|
||||
LOG = logging.getLogger("JELLYFIN." + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
|
||||
#################################################################################################
|
||||
|
||||
|
@ -51,7 +51,6 @@ class Service(xbmc.Monitor):
|
|||
self.settings['enable_context'] = settings('enableContext.bool')
|
||||
self.settings['enable_context_transcode'] = settings('enableContextTranscode.bool')
|
||||
self.settings['kodi_companion'] = settings('kodiCompanion.bool')
|
||||
window('jellyfin_logLevel', value=str(self.settings['log_level']))
|
||||
window('jellyfin_kodiProfile', value=self.settings['profile'])
|
||||
settings('platformDetected', client.get_platform())
|
||||
|
||||
|
@ -356,7 +355,6 @@ class Service(xbmc.Monitor):
|
|||
if settings('logLevel') != self.settings['log_level']:
|
||||
|
||||
log_level = settings('logLevel')
|
||||
window('jellyfin_logLevel', str(log_level))
|
||||
self.settings['logLevel'] = log_level
|
||||
LOG.info("New log level: %s", log_level)
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
|
||||
from contextlib import contextmanager
|
||||
import datetime
|
||||
import logging
|
||||
|
||||
from kodi_six import xbmc
|
||||
|
||||
|
@ -15,10 +14,11 @@ from objects import Movies, TVShows, MusicVideos, Music
|
|||
from database import Database, get_sync, save_sync, jellyfin_db
|
||||
from helper import translate, settings, window, progress, dialog, LibraryException
|
||||
from helper.utils import get_screensaver, set_screensaver
|
||||
from helper import LazyLogger
|
||||
|
||||
##################################################################################################
|
||||
|
||||
LOG = logging.getLogger("JELLYFIN." + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
|
||||
##################################################################################################
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
from __future__ import division, absolute_import, print_function, unicode_literals
|
||||
|
||||
from .lazylogger import LazyLogger
|
||||
|
||||
from .translate import translate
|
||||
from .exceptions import LibraryException
|
||||
|
||||
|
|
|
@ -3,13 +3,13 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
|
||||
##################################################################################################
|
||||
|
||||
import logging
|
||||
from helper import LazyLogger
|
||||
|
||||
from . import settings
|
||||
|
||||
##################################################################################################
|
||||
|
||||
LOG = logging.getLogger("JELLYFIN." + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
|
||||
##################################################################################################
|
||||
|
||||
|
|
19
jellyfin_kodi/helper/lazylogger.py
Normal file
19
jellyfin_kodi/helper/lazylogger.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import division, absolute_import, print_function, unicode_literals
|
||||
|
||||
|
||||
class LazyLogger(object):
|
||||
"""`helper.loghandler.getLogger()` is used everywhere.
|
||||
This class helps avoiding import errors.
|
||||
"""
|
||||
__logger = None
|
||||
__logger_name = None
|
||||
|
||||
def __init__(self, logger_name=None):
|
||||
self.__logger_name = logger_name
|
||||
|
||||
def __getattr__(self, name):
|
||||
if self.__logger is None:
|
||||
from helper.loghandler import getLogger
|
||||
self.__logger = getLogger(self.__logger_name)
|
||||
return getattr(self.__logger, name)
|
|
@ -1,9 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import division, absolute_import, print_function, unicode_literals
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import print_function
|
||||
|
||||
##################################################################################################
|
||||
|
||||
import os
|
||||
|
@ -13,7 +10,7 @@ import traceback
|
|||
from kodi_six import xbmc, xbmcaddon
|
||||
import database
|
||||
|
||||
from . import window, settings
|
||||
from . import settings
|
||||
|
||||
##################################################################################################
|
||||
|
||||
|
@ -23,17 +20,11 @@ __pluginpath__ = xbmc.translatePath(__addon__.getAddonInfo('path'))
|
|||
##################################################################################################
|
||||
|
||||
|
||||
def config():
|
||||
def getLogger(name=None):
|
||||
if name is None:
|
||||
return __LOGGER
|
||||
|
||||
logger = logging.getLogger('JELLYFIN')
|
||||
logger.addHandler(LogHandler())
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
||||
|
||||
def reset():
|
||||
|
||||
for handler in logging.getLogger('JELLYFIN').handlers:
|
||||
logging.getLogger('JELLYFIN').removeHandler(handler)
|
||||
return __LOGGER.getChild(name)
|
||||
|
||||
|
||||
class LogHandler(logging.StreamHandler):
|
||||
|
@ -70,9 +61,6 @@ class LogHandler(logging.StreamHandler):
|
|||
for token in self.sensitive['Token']:
|
||||
string = string.replace(token or "{token}", "{jellyfin-token}")
|
||||
|
||||
try:
|
||||
xbmc.log(string, level=xbmc.LOGNOTICE)
|
||||
except UnicodeEncodeError:
|
||||
xbmc.log(string, level=xbmc.LOGNOTICE)
|
||||
|
||||
@classmethod
|
||||
|
@ -85,36 +73,24 @@ class LogHandler(logging.StreamHandler):
|
|||
logging.DEBUG: 2
|
||||
}
|
||||
try:
|
||||
log_level = int(window('jellyfin_logLevel'))
|
||||
log_level = int(settings('logLevel'))
|
||||
except ValueError:
|
||||
log_level = 0
|
||||
log_level = 2 # If getting settings fail, we probably want debug logging.
|
||||
|
||||
return log_level >= levels[level]
|
||||
|
||||
|
||||
class MyFormatter(logging.Formatter):
|
||||
|
||||
def __init__(self, fmt="%(name)s -> %(message)s"):
|
||||
|
||||
def __init__(self, fmt='%(name)s -> %(levelname)s::%(relpath)s:%(lineno)s %(message)s'):
|
||||
logging.Formatter.__init__(self, fmt)
|
||||
|
||||
def format(self, record):
|
||||
|
||||
# Save the original format configured by the user
|
||||
# when the logger formatter was instantiated
|
||||
format_orig = self._fmt
|
||||
|
||||
self._gen_rel_path(record)
|
||||
|
||||
# Replace the original format with one customized by logging level
|
||||
self._fmt = '%(name)s -> %(levelname)s::%(relpath)s:%(lineno)s %(message)s'
|
||||
|
||||
# Call the original formatter class to do the grunt work
|
||||
result = logging.Formatter.format(self, record)
|
||||
|
||||
# Restore the original format configured by the user
|
||||
self._fmt = format_orig
|
||||
|
||||
return result
|
||||
|
||||
def formatException(self, exc_info):
|
||||
|
@ -136,3 +112,11 @@ class MyFormatter(logging.Formatter):
|
|||
def _gen_rel_path(self, record):
|
||||
if record.pathname:
|
||||
record.relpath = os.path.relpath(record.pathname, __pluginpath__)
|
||||
|
||||
|
||||
__LOGGER = logging.getLogger('JELLYFIN')
|
||||
for handler in __LOGGER.handlers:
|
||||
__LOGGER.removeHandler(handler)
|
||||
|
||||
__LOGGER.addHandler(LogHandler())
|
||||
__LOGGER.setLevel(logging.DEBUG)
|
||||
|
|
|
@ -3,7 +3,6 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
|
||||
#################################################################################################
|
||||
|
||||
import logging
|
||||
import os
|
||||
from uuid import uuid4
|
||||
import collections
|
||||
|
@ -15,10 +14,11 @@ import requests
|
|||
from downloader import TheVoid
|
||||
|
||||
from . import translate, settings, window, dialog, api
|
||||
from helper import LazyLogger
|
||||
|
||||
#################################################################################################
|
||||
|
||||
LOG = logging.getLogger("JELLYFIN." + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
|
||||
#################################################################################################
|
||||
|
||||
|
|
|
@ -3,13 +3,13 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
|
||||
##################################################################################################
|
||||
|
||||
import logging
|
||||
|
||||
from kodi_six import xbmc, xbmcaddon
|
||||
|
||||
from helper import LazyLogger
|
||||
|
||||
##################################################################################################
|
||||
|
||||
LOG = logging.getLogger('JELLYFIN.' + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
|
||||
##################################################################################################
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
|
||||
import binascii
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import unicodedata
|
||||
|
@ -18,11 +17,12 @@ from six.moves.urllib.parse import quote_plus
|
|||
|
||||
from kodi_six import xbmc, xbmcaddon, xbmcgui, xbmcvfs
|
||||
|
||||
from . import LazyLogger
|
||||
from .translate import translate
|
||||
|
||||
#################################################################################################
|
||||
|
||||
LOG = logging.getLogger("JELLYFIN." + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
|
||||
#################################################################################################
|
||||
|
||||
|
|
|
@ -3,17 +3,17 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
|
||||
#################################################################################################
|
||||
|
||||
import logging
|
||||
|
||||
from kodi_six import xbmcgui
|
||||
|
||||
from helper import LazyLogger
|
||||
|
||||
from .utils import should_stop
|
||||
from .exceptions import LibraryException
|
||||
from .translate import translate
|
||||
|
||||
#################################################################################################
|
||||
|
||||
LOG = logging.getLogger("JELLYFIN." + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
|
||||
#################################################################################################
|
||||
|
||||
|
|
|
@ -3,17 +3,18 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
|
||||
#################################################################################################
|
||||
|
||||
import logging
|
||||
import os
|
||||
import xml.etree.ElementTree as etree
|
||||
|
||||
from kodi_six import xbmc
|
||||
|
||||
from helper import LazyLogger
|
||||
|
||||
from . import translate, dialog, settings
|
||||
|
||||
#################################################################################################
|
||||
|
||||
LOG = logging.getLogger("JELLYFIN." + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
|
||||
#################################################################################################
|
||||
|
||||
|
|
|
@ -6,29 +6,15 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
import logging
|
||||
|
||||
from .client import JellyfinClient
|
||||
from helper import has_attribute
|
||||
from helper import has_attribute, LazyLogger
|
||||
|
||||
#################################################################################################
|
||||
|
||||
|
||||
class NullHandler(logging.Handler):
|
||||
def emit(self, record):
|
||||
print(self.format(record))
|
||||
|
||||
|
||||
loghandler = NullHandler
|
||||
LOG = logging.getLogger('Jellyfin')
|
||||
LOG = LazyLogger()
|
||||
|
||||
#################################################################################################
|
||||
|
||||
|
||||
def config(level=logging.INFO):
|
||||
|
||||
logger = logging.getLogger('Jellyfin')
|
||||
logger.addHandler(Jellyfin.loghandler())
|
||||
logger.setLevel(level)
|
||||
|
||||
|
||||
def ensure_client():
|
||||
|
||||
def decorator(func):
|
||||
|
@ -61,7 +47,6 @@ class Jellyfin(object):
|
|||
_shared_state = {}
|
||||
client = {}
|
||||
server_id = "default"
|
||||
loghandler = loghandler
|
||||
|
||||
def __init__(self, server_id=None):
|
||||
self.__dict__ = self._shared_state
|
||||
|
@ -70,16 +55,6 @@ class Jellyfin(object):
|
|||
def get_client(self):
|
||||
return self.client[self.server_id]
|
||||
|
||||
@classmethod
|
||||
def set_loghandler(cls, func=loghandler, level=logging.INFO):
|
||||
|
||||
for handler in logging.getLogger('Jellyfin').handlers:
|
||||
if isinstance(handler, cls.loghandler):
|
||||
logging.getLogger('Jellyfin').removeHandler(handler)
|
||||
|
||||
cls.loghandler = func
|
||||
config(level)
|
||||
|
||||
def close(self):
|
||||
|
||||
if self.server_id not in self.client:
|
||||
|
@ -123,6 +98,3 @@ class Jellyfin(object):
|
|||
LOG.info("---[ START JELLYFINCLIENT ]---")
|
||||
else:
|
||||
LOG.info("---[ START JELLYFINCLIENT: %s ]---", self.server_id)
|
||||
|
||||
|
||||
config()
|
||||
|
|
|
@ -2,10 +2,12 @@
|
|||
from __future__ import division, absolute_import, print_function, unicode_literals
|
||||
import requests
|
||||
import json
|
||||
import logging
|
||||
from helper.utils import settings
|
||||
|
||||
LOG = logging.getLogger('JELLYFIN.' + __name__)
|
||||
from helper.utils import settings
|
||||
from helper import LazyLogger
|
||||
|
||||
|
||||
LOG = LazyLogger(__name__)
|
||||
|
||||
|
||||
def jellyfin_url(client, handler):
|
||||
|
|
|
@ -3,7 +3,7 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
|
||||
#################################################################################################
|
||||
|
||||
import logging
|
||||
from helper import LazyLogger
|
||||
|
||||
from . import api
|
||||
from .configuration import Config
|
||||
|
@ -13,7 +13,7 @@ from .connection_manager import ConnectionManager, CONNECTION_STATE
|
|||
|
||||
#################################################################################################
|
||||
|
||||
LOG = logging.getLogger('JELLYFIN.' + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
|
||||
#################################################################################################
|
||||
|
||||
|
|
|
@ -7,13 +7,13 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
|
||||
#################################################################################################
|
||||
|
||||
import logging
|
||||
from helper import LazyLogger
|
||||
|
||||
#################################################################################################
|
||||
|
||||
LOG = LazyLogger(__name__)
|
||||
DEFAULT_HTTP_MAX_RETRIES = 3
|
||||
DEFAULT_HTTP_TIMEOUT = 30
|
||||
LOG = logging.getLogger('JELLYFIN.' + __name__)
|
||||
|
||||
#################################################################################################
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
#################################################################################################
|
||||
|
||||
import json
|
||||
import logging
|
||||
import socket
|
||||
import time
|
||||
from datetime import datetime
|
||||
|
@ -16,10 +15,11 @@ from .credentials import Credentials
|
|||
from .http import HTTP # noqa: I201,I100
|
||||
from .api import API
|
||||
import traceback
|
||||
from helper import LazyLogger
|
||||
|
||||
#################################################################################################
|
||||
|
||||
LOG = logging.getLogger('JELLYFIN.' + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
CONNECTION_STATE = {
|
||||
'Unavailable': 0,
|
||||
'ServerSelection': 1,
|
||||
|
|
|
@ -3,13 +3,14 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
|
||||
#################################################################################################
|
||||
|
||||
import logging
|
||||
import time
|
||||
from datetime import datetime
|
||||
|
||||
from helper import LazyLogger
|
||||
|
||||
#################################################################################################
|
||||
|
||||
LOG = logging.getLogger('JELLYFIN.' + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
|
||||
#################################################################################################
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
#################################################################################################
|
||||
|
||||
import json
|
||||
import logging
|
||||
import time
|
||||
|
||||
import requests
|
||||
|
@ -12,10 +11,11 @@ from six import string_types
|
|||
|
||||
from .exceptions import HTTPException
|
||||
from helper.utils import JsonDebugPrinter
|
||||
from helper import LazyLogger
|
||||
|
||||
#################################################################################################
|
||||
|
||||
LOG = logging.getLogger('Jellyfin.' + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
|
||||
#################################################################################################
|
||||
|
||||
|
|
|
@ -4,16 +4,17 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
#################################################################################################
|
||||
|
||||
import json
|
||||
import logging
|
||||
import threading
|
||||
|
||||
from kodi_six import xbmc
|
||||
|
||||
from helper import LazyLogger
|
||||
|
||||
from . import websocket
|
||||
|
||||
##################################################################################################
|
||||
|
||||
LOG = logging.getLogger('JELLYFIN.' + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
|
||||
##################################################################################################
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
|
||||
##################################################################################################
|
||||
|
||||
import logging
|
||||
import threading
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
|
@ -19,10 +18,11 @@ from downloader import GetItemWorker
|
|||
from helper import translate, api, stop, settings, window, dialog, event, LibraryException
|
||||
from helper.utils import split_list, set_screensaver, get_screensaver
|
||||
from jellyfin import Jellyfin
|
||||
from helper import LazyLogger
|
||||
|
||||
##################################################################################################
|
||||
|
||||
LOG = logging.getLogger("JELLYFIN." + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
LIMIT = int(settings('limitIndex') or 15)
|
||||
DTHREADS = int(settings('limitThreads') or 3)
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
|
||||
import binascii
|
||||
import json
|
||||
import logging
|
||||
import threading
|
||||
|
||||
from kodi_six import xbmc
|
||||
|
@ -19,10 +18,11 @@ from helper import translate, settings, window, dialog, api, JSONRPC
|
|||
from helper.utils import JsonDebugPrinter
|
||||
from jellyfin import Jellyfin
|
||||
from webservice import WebService
|
||||
from helper import LazyLogger
|
||||
|
||||
#################################################################################################
|
||||
|
||||
LOG = logging.getLogger("JELLYFIN." + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
|
||||
#################################################################################################
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
|
||||
#################################################################################################
|
||||
|
||||
import logging
|
||||
import threading
|
||||
import sys
|
||||
from datetime import timedelta
|
||||
|
@ -15,10 +14,11 @@ from downloader import TheVoid
|
|||
from .obj import Objects
|
||||
from helper import translate, playutils, api, window, settings, dialog
|
||||
from dialogs import resume
|
||||
from helper import LazyLogger
|
||||
|
||||
#################################################################################################
|
||||
|
||||
LOG = logging.getLogger("JELLYFIN." + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
|
||||
#################################################################################################
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
|
||||
#################################################################################################
|
||||
|
||||
import logging
|
||||
import threading
|
||||
|
||||
from six.moves import queue as Queue
|
||||
|
@ -15,10 +14,11 @@ from . import queries as QU
|
|||
from . import queries_texture as QUTEX
|
||||
from helper import settings
|
||||
import requests
|
||||
from helper import LazyLogger
|
||||
|
||||
##################################################################################################
|
||||
|
||||
LOG = logging.getLogger("JELLYFIN." + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
|
||||
##################################################################################################
|
||||
|
||||
|
|
|
@ -3,16 +3,15 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
|
||||
##################################################################################################
|
||||
|
||||
import logging
|
||||
|
||||
from . import artwork
|
||||
from . import queries as QU
|
||||
from helper import values
|
||||
from sqlite3 import IntegrityError
|
||||
from helper import LazyLogger
|
||||
|
||||
##################################################################################################
|
||||
|
||||
LOG = logging.getLogger("JELLYFIN." + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
|
||||
##################################################################################################
|
||||
|
||||
|
|
|
@ -3,14 +3,14 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
|
||||
##################################################################################################
|
||||
|
||||
import logging
|
||||
from helper import LazyLogger
|
||||
|
||||
from .kodi import Kodi
|
||||
from . import queries as QU
|
||||
|
||||
##################################################################################################
|
||||
|
||||
LOG = logging.getLogger("JELLYFIN." + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
|
||||
##################################################################################################
|
||||
|
||||
|
|
|
@ -3,14 +3,14 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
|
||||
##################################################################################################
|
||||
|
||||
import logging
|
||||
from helper import LazyLogger
|
||||
|
||||
from . import queries_music as QU
|
||||
from .kodi import Kodi
|
||||
|
||||
##################################################################################################
|
||||
|
||||
LOG = logging.getLogger("JELLYFIN." + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
|
||||
##################################################################################################
|
||||
|
||||
|
|
|
@ -3,14 +3,14 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
|
||||
##################################################################################################
|
||||
|
||||
import logging
|
||||
from helper import LazyLogger
|
||||
|
||||
from . import queries as QU
|
||||
from .kodi import Kodi
|
||||
|
||||
##################################################################################################
|
||||
|
||||
log = logging.getLogger("JELLYFIN." + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
|
||||
##################################################################################################
|
||||
|
||||
|
|
|
@ -3,14 +3,14 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
|
||||
##################################################################################################
|
||||
|
||||
import logging
|
||||
from helper import LazyLogger
|
||||
|
||||
from . import queries as QU
|
||||
from .kodi import Kodi
|
||||
|
||||
##################################################################################################
|
||||
|
||||
LOG = logging.getLogger("JELLYFIN." + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
|
||||
##################################################################################################
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
|
||||
##################################################################################################
|
||||
|
||||
import logging
|
||||
from six.moves.urllib.parse import urlencode
|
||||
from kodi_six.utils import py2_encode
|
||||
|
||||
|
@ -12,10 +11,11 @@ from .obj import Objects
|
|||
from .kodi import Movies as KodiDb, queries as QU
|
||||
from database import jellyfin_db, queries as QUEM
|
||||
from helper import api, stop, validate, jellyfin_item, library_check, values, settings, Local
|
||||
from helper import LazyLogger
|
||||
|
||||
##################################################################################################
|
||||
|
||||
LOG = logging.getLogger("JELLYFIN." + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
|
||||
##################################################################################################
|
||||
|
||||
|
|
|
@ -4,16 +4,16 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
##################################################################################################
|
||||
|
||||
import datetime
|
||||
import logging
|
||||
|
||||
from .obj import Objects
|
||||
from .kodi import Music as KodiDb, queries_music as QU
|
||||
from database import jellyfin_db, queries as QUEM
|
||||
from helper import api, stop, validate, jellyfin_item, values, library_check, Local
|
||||
from helper import LazyLogger
|
||||
|
||||
##################################################################################################
|
||||
|
||||
LOG = logging.getLogger("JELLYFIN." + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
|
||||
##################################################################################################
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
##################################################################################################
|
||||
|
||||
import datetime
|
||||
import logging
|
||||
import re
|
||||
from six.moves.urllib.parse import urlencode
|
||||
from kodi_six.utils import py2_encode
|
||||
|
@ -13,10 +12,11 @@ from .obj import Objects
|
|||
from .kodi import MusicVideos as KodiDb, queries as QU
|
||||
from database import jellyfin_db, queries as QUEM
|
||||
from helper import api, stop, validate, library_check, jellyfin_item, values, Local
|
||||
from helper import LazyLogger
|
||||
|
||||
##################################################################################################
|
||||
|
||||
LOG = logging.getLogger("JELLYFIN." + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
|
||||
##################################################################################################
|
||||
|
||||
|
|
|
@ -4,14 +4,15 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
##################################################################################################
|
||||
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
|
||||
from six import iteritems
|
||||
|
||||
from helper import LazyLogger
|
||||
|
||||
##################################################################################################
|
||||
|
||||
LOG = logging.getLogger("JELLYFIN." + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
|
||||
##################################################################################################
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
|
||||
##################################################################################################
|
||||
|
||||
import logging
|
||||
import sqlite3
|
||||
from ntpath import dirname
|
||||
|
||||
|
@ -15,10 +14,11 @@ from .kodi import TVShows as KodiDb, queries as QU
|
|||
import downloader as server
|
||||
from database import jellyfin_db, queries as QUEM
|
||||
from helper import api, stop, validate, jellyfin_item, library_check, settings, values, Local
|
||||
from helper import LazyLogger
|
||||
|
||||
##################################################################################################
|
||||
|
||||
LOG = logging.getLogger("JELLYFIN." + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
|
||||
##################################################################################################
|
||||
|
||||
|
|
|
@ -3,13 +3,12 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
|
||||
#################################################################################################
|
||||
|
||||
import logging
|
||||
|
||||
from helper import JSONRPC
|
||||
from helper import LazyLogger
|
||||
|
||||
#################################################################################################
|
||||
|
||||
LOG = logging.getLogger("JELLYFIN." + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
|
||||
#################################################################################################
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
|
||||
#################################################################################################
|
||||
|
||||
import logging
|
||||
import os
|
||||
|
||||
from kodi_six import xbmc, xbmcvfs
|
||||
|
@ -11,10 +10,11 @@ from kodi_six import xbmc, xbmcvfs
|
|||
from objects.obj import Objects
|
||||
from helper import translate, api, window, settings, dialog, event, silent_catch, JSONRPC
|
||||
from jellyfin import Jellyfin
|
||||
from helper import LazyLogger
|
||||
|
||||
#################################################################################################
|
||||
|
||||
LOG = logging.getLogger("JELLYFIN." + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
|
||||
#################################################################################################
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
|
||||
#################################################################################################
|
||||
|
||||
import logging
|
||||
import os
|
||||
import shutil
|
||||
import xml.etree.ElementTree as etree
|
||||
|
@ -14,10 +13,11 @@ from kodi_six import xbmc, xbmcvfs
|
|||
from database import Database, jellyfin_db, get_sync, save_sync
|
||||
from helper import translate, api, window, event
|
||||
from jellyfin import Jellyfin
|
||||
from helper import LazyLogger
|
||||
|
||||
#################################################################################################
|
||||
|
||||
LOG = logging.getLogger("JELLYFIN." + __name__)
|
||||
LOG = LazyLogger(__name__)
|
||||
NODES = {
|
||||
'tvshows': [
|
||||
('all', None),
|
||||
|
|
|
@ -4,17 +4,18 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
#################################################################################################
|
||||
|
||||
from six.moves import BaseHTTPServer
|
||||
import logging
|
||||
from six.moves import http_client as httplib
|
||||
import threading
|
||||
from six.moves.urllib.parse import parse_qsl
|
||||
|
||||
from kodi_six import xbmc
|
||||
|
||||
from helper import LazyLogger
|
||||
|
||||
#################################################################################################
|
||||
|
||||
LOG = LazyLogger(__name__)
|
||||
PORT = 57578
|
||||
LOG = logging.getLogger("JELLYFIN." + __name__)
|
||||
|
||||
#################################################################################################
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
|
||||
#################################################################################################
|
||||
|
||||
import logging
|
||||
import os
|
||||
import threading
|
||||
import sys
|
||||
|
@ -21,10 +20,11 @@ sys.path.insert(0, __base__)
|
|||
|
||||
from entrypoint import Service # noqa: F402
|
||||
from helper.utils import settings # noqa: F402
|
||||
from helper import LazyLogger # noqa: F402
|
||||
|
||||
#################################################################################################
|
||||
|
||||
LOG = logging.getLogger("JELLYFIN.service")
|
||||
LOG = LazyLogger(__name__)
|
||||
DELAY = int(settings('startupDelay') if settings('SyncInstallRunDone.bool') else 4 or 0)
|
||||
|
||||
#################################################################################################
|
||||
|
|
Loading…
Reference in a new issue