From 795dfd38dff1b5f0edc27cbee39e6a7a4427939f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odd=20Str=C3=A5b=C3=B8?= Date: Sun, 19 Apr 2020 03:05:59 +0200 Subject: [PATCH 1/3] Get the logger from a central place --- context.py | 4 +-- context_play.py | 4 +-- default.py | 4 +-- jellyfin_kodi/client.py | 6 ++-- jellyfin_kodi/connect.py | 5 ++- jellyfin_kodi/database/__init__.py | 3 +- jellyfin_kodi/database/jellyfin_db.py | 5 ++- jellyfin_kodi/dialogs/context.py | 4 +-- jellyfin_kodi/dialogs/loginmanual.py | 4 +-- jellyfin_kodi/dialogs/resume.py | 6 ++-- jellyfin_kodi/dialogs/serverconnect.py | 5 ++- jellyfin_kodi/dialogs/servermanual.py | 4 +-- jellyfin_kodi/dialogs/usersconnect.py | 6 ++-- jellyfin_kodi/downloader.py | 4 +-- jellyfin_kodi/entrypoint/__init__.py | 7 ++--- jellyfin_kodi/entrypoint/context.py | 4 +-- jellyfin_kodi/entrypoint/default.py | 4 +-- jellyfin_kodi/entrypoint/service.py | 6 ++-- jellyfin_kodi/full_sync.py | 4 +-- jellyfin_kodi/helper/__init__.py | 2 ++ jellyfin_kodi/helper/api.py | 4 +-- jellyfin_kodi/helper/lazylogger.py | 19 ++++++++++++ jellyfin_kodi/helper/loghandler.py | 31 +++++++++---------- jellyfin_kodi/helper/playutils.py | 4 +-- jellyfin_kodi/helper/translate.py | 6 ++-- jellyfin_kodi/helper/utils.py | 4 +-- jellyfin_kodi/helper/wrapper.py | 6 ++-- jellyfin_kodi/helper/xmls.py | 5 +-- jellyfin_kodi/jellyfin/__init__.py | 32 ++------------------ jellyfin_kodi/jellyfin/api.py | 8 +++-- jellyfin_kodi/jellyfin/client.py | 4 +-- jellyfin_kodi/jellyfin/configuration.py | 10 +++--- jellyfin_kodi/jellyfin/connection_manager.py | 4 +-- jellyfin_kodi/jellyfin/credentials.py | 5 +-- jellyfin_kodi/jellyfin/http.py | 6 ++-- jellyfin_kodi/jellyfin/ws_client.py | 5 +-- jellyfin_kodi/library.py | 4 +-- jellyfin_kodi/monitor.py | 4 +-- jellyfin_kodi/objects/actions.py | 4 +-- jellyfin_kodi/objects/kodi/artwork.py | 4 +-- jellyfin_kodi/objects/kodi/kodi.py | 5 ++- jellyfin_kodi/objects/kodi/movies.py | 4 +-- jellyfin_kodi/objects/kodi/music.py | 4 +-- jellyfin_kodi/objects/kodi/musicvideos.py | 4 +-- jellyfin_kodi/objects/kodi/tvshows.py | 4 +-- jellyfin_kodi/objects/movies.py | 4 +-- jellyfin_kodi/objects/music.py | 4 +-- jellyfin_kodi/objects/musicvideos.py | 4 +-- jellyfin_kodi/objects/obj.py | 5 +-- jellyfin_kodi/objects/tvshows.py | 4 +-- jellyfin_kodi/objects/utils.py | 5 ++- jellyfin_kodi/player.py | 4 +-- jellyfin_kodi/views.py | 4 +-- jellyfin_kodi/webservice.py | 5 +-- service.py | 4 +-- 55 files changed, 157 insertions(+), 167 deletions(-) create mode 100644 jellyfin_kodi/helper/lazylogger.py diff --git a/context.py b/context.py index 513b4be4..c3cba508 100644 --- a/context.py +++ b/context.py @@ -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("context") ################################################################################################# diff --git a/context_play.py b/context_play.py index aa657e31..48e3cc15 100644 --- a/context_play.py +++ b/context_play.py @@ -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("context_play") ################################################################################################# diff --git a/default.py b/default.py index f96d0970..210bf991 100644 --- a/default.py +++ b/default.py @@ -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("default") ################################################################################################# diff --git a/jellyfin_kodi/client.py b/jellyfin_kodi/client.py index 2eb63e4b..ab80c49a 100644 --- a/jellyfin_kodi/client.py +++ b/jellyfin_kodi/client.py @@ -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__) ################################################################################################## @@ -104,7 +104,7 @@ def get_device_id(reset=False): file_guid.close() LOG.debug("DeviceId loaded: %s", client_id) window('jellyfin_deviceId', value=client_id) - + return client_id diff --git a/jellyfin_kodi/connect.py b/jellyfin_kodi/connect.py index 16694fa3..cc535370 100644 --- a/jellyfin_kodi/connect.py +++ b/jellyfin_kodi/connect.py @@ -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") ################################################################################################## diff --git a/jellyfin_kodi/database/__init__.py b/jellyfin_kodi/database/__init__.py index cefac240..54a2fa51 100644 --- a/jellyfin_kodi/database/__init__.py +++ b/jellyfin_kodi/database/__init__.py @@ -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__) ################################################################################################# diff --git a/jellyfin_kodi/database/jellyfin_db.py b/jellyfin_kodi/database/jellyfin_db.py index 3367ab51..97f1e23f 100644 --- a/jellyfin_kodi/database/jellyfin_db.py +++ b/jellyfin_kodi/database/jellyfin_db.py @@ -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__) ################################################################################################## diff --git a/jellyfin_kodi/dialogs/context.py b/jellyfin_kodi/dialogs/context.py index de66ba49..7f90872d 100644 --- a/jellyfin_kodi/dialogs/context.py +++ b/jellyfin_kodi/dialogs/context.py @@ -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 diff --git a/jellyfin_kodi/dialogs/loginmanual.py b/jellyfin_kodi/dialogs/loginmanual.py index c93326d1..c8749b9c 100644 --- a/jellyfin_kodi/dialogs/loginmanual.py +++ b/jellyfin_kodi/dialogs/loginmanual.py @@ -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 diff --git a/jellyfin_kodi/dialogs/resume.py b/jellyfin_kodi/dialogs/resume.py index 716cda4e..9639227a 100644 --- a/jellyfin_kodi/dialogs/resume.py +++ b/jellyfin_kodi/dialogs/resume.py @@ -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 diff --git a/jellyfin_kodi/dialogs/serverconnect.py b/jellyfin_kodi/dialogs/serverconnect.py index 101dcd4e..95f31c91 100644 --- a/jellyfin_kodi/dialogs/serverconnect.py +++ b/jellyfin_kodi/dialogs/serverconnect.py @@ -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 diff --git a/jellyfin_kodi/dialogs/servermanual.py b/jellyfin_kodi/dialogs/servermanual.py index c1970fa5..469d3099 100644 --- a/jellyfin_kodi/dialogs/servermanual.py +++ b/jellyfin_kodi/dialogs/servermanual.py @@ -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 diff --git a/jellyfin_kodi/dialogs/usersconnect.py b/jellyfin_kodi/dialogs/usersconnect.py index 84faf4e2..414fa51f 100644 --- a/jellyfin_kodi/dialogs/usersconnect.py +++ b/jellyfin_kodi/dialogs/usersconnect.py @@ -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 diff --git a/jellyfin_kodi/downloader.py b/jellyfin_kodi/downloader.py index 1efd9ddb..a1e42297 100644 --- a/jellyfin_kodi/downloader.py +++ b/jellyfin_kodi/downloader.py @@ -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) diff --git a/jellyfin_kodi/entrypoint/__init__.py b/jellyfin_kodi/entrypoint/__init__.py index 23cc4476..ebb84487 100644 --- a/jellyfin_kodi/entrypoint/__init__.py +++ b/jellyfin_kodi/entrypoint/__init__.py @@ -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("entrypoint") ################################################################################################# diff --git a/jellyfin_kodi/entrypoint/context.py b/jellyfin_kodi/entrypoint/context.py index 01b5f801..5b0b6ad5 100644 --- a/jellyfin_kodi/entrypoint/context.py +++ b/jellyfin_kodi/entrypoint/context.py @@ -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), diff --git a/jellyfin_kodi/entrypoint/default.py b/jellyfin_kodi/entrypoint/default.py index 760601ce..288fdc4f 100644 --- a/jellyfin_kodi/entrypoint/default.py +++ b/jellyfin_kodi/entrypoint/default.py @@ -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__) ################################################################################################# diff --git a/jellyfin_kodi/entrypoint/service.py b/jellyfin_kodi/entrypoint/service.py index acf61bbb..5ecc0b44 100644 --- a/jellyfin_kodi/entrypoint/service.py +++ b/jellyfin_kodi/entrypoint/service.py @@ -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) diff --git a/jellyfin_kodi/full_sync.py b/jellyfin_kodi/full_sync.py index 6c3ea2b6..8969e838 100644 --- a/jellyfin_kodi/full_sync.py +++ b/jellyfin_kodi/full_sync.py @@ -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__) ################################################################################################## diff --git a/jellyfin_kodi/helper/__init__.py b/jellyfin_kodi/helper/__init__.py index 0d51b89e..d958bec8 100644 --- a/jellyfin_kodi/helper/__init__.py +++ b/jellyfin_kodi/helper/__init__.py @@ -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 diff --git a/jellyfin_kodi/helper/api.py b/jellyfin_kodi/helper/api.py index 2a175455..441fe33e 100644 --- a/jellyfin_kodi/helper/api.py +++ b/jellyfin_kodi/helper/api.py @@ -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__) ################################################################################################## diff --git a/jellyfin_kodi/helper/lazylogger.py b/jellyfin_kodi/helper/lazylogger.py new file mode 100644 index 00000000..52534ec2 --- /dev/null +++ b/jellyfin_kodi/helper/lazylogger.py @@ -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) diff --git a/jellyfin_kodi/helper/loghandler.py b/jellyfin_kodi/helper/loghandler.py index c067a960..2d3ec659 100644 --- a/jellyfin_kodi/helper/loghandler.py +++ b/jellyfin_kodi/helper/loghandler.py @@ -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): @@ -85,9 +76,9 @@ 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] @@ -136,3 +127,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) diff --git a/jellyfin_kodi/helper/playutils.py b/jellyfin_kodi/helper/playutils.py index d4fbaec8..7ee21cb1 100644 --- a/jellyfin_kodi/helper/playutils.py +++ b/jellyfin_kodi/helper/playutils.py @@ -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__) ################################################################################################# diff --git a/jellyfin_kodi/helper/translate.py b/jellyfin_kodi/helper/translate.py index d140b149..8b75b1de 100644 --- a/jellyfin_kodi/helper/translate.py +++ b/jellyfin_kodi/helper/translate.py @@ -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__) ################################################################################################## diff --git a/jellyfin_kodi/helper/utils.py b/jellyfin_kodi/helper/utils.py index 37ff8ba0..84da6b6c 100644 --- a/jellyfin_kodi/helper/utils.py +++ b/jellyfin_kodi/helper/utils.py @@ -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__) ################################################################################################# diff --git a/jellyfin_kodi/helper/wrapper.py b/jellyfin_kodi/helper/wrapper.py index ccd49bdd..a0487a8a 100644 --- a/jellyfin_kodi/helper/wrapper.py +++ b/jellyfin_kodi/helper/wrapper.py @@ -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__) ################################################################################################# diff --git a/jellyfin_kodi/helper/xmls.py b/jellyfin_kodi/helper/xmls.py index a1bfe873..82c1441e 100644 --- a/jellyfin_kodi/helper/xmls.py +++ b/jellyfin_kodi/helper/xmls.py @@ -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__) ################################################################################################# diff --git a/jellyfin_kodi/jellyfin/__init__.py b/jellyfin_kodi/jellyfin/__init__.py index 19dba025..38d33472 100644 --- a/jellyfin_kodi/jellyfin/__init__.py +++ b/jellyfin_kodi/jellyfin/__init__.py @@ -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() diff --git a/jellyfin_kodi/jellyfin/api.py b/jellyfin_kodi/jellyfin/api.py index 238a2787..cbf2e552 100644 --- a/jellyfin_kodi/jellyfin/api.py +++ b/jellyfin_kodi/jellyfin/api.py @@ -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): diff --git a/jellyfin_kodi/jellyfin/client.py b/jellyfin_kodi/jellyfin/client.py index d326f409..0da2975e 100644 --- a/jellyfin_kodi/jellyfin/client.py +++ b/jellyfin_kodi/jellyfin/client.py @@ -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__) ################################################################################################# diff --git a/jellyfin_kodi/jellyfin/configuration.py b/jellyfin_kodi/jellyfin/configuration.py index 1d93ef9e..0b6607e6 100644 --- a/jellyfin_kodi/jellyfin/configuration.py +++ b/jellyfin_kodi/jellyfin/configuration.py @@ -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__) ################################################################################################# @@ -27,7 +27,7 @@ class Config(object): self.http() def app(self, name, version, device_name, device_id, capabilities=None, device_pixel_ratio=None): - + LOG.debug("Begin app constructor.") self.data['app.name'] = name self.data['app.version'] = version @@ -38,7 +38,7 @@ class Config(object): self.data['app.default'] = False def auth(self, server, user_id, token=None, ssl=None): - + LOG.debug("Begin auth constructor.") self.data['auth.server'] = server self.data['auth.user_id'] = user_id @@ -46,7 +46,7 @@ class Config(object): self.data['auth.ssl'] = ssl def http(self, user_agent=None, max_retries=DEFAULT_HTTP_MAX_RETRIES, timeout=DEFAULT_HTTP_TIMEOUT): - + LOG.debug("Begin http constructor.") self.data['http.max_retries'] = max_retries self.data['http.timeout'] = timeout diff --git a/jellyfin_kodi/jellyfin/connection_manager.py b/jellyfin_kodi/jellyfin/connection_manager.py index 67a6c741..353ce022 100644 --- a/jellyfin_kodi/jellyfin/connection_manager.py +++ b/jellyfin_kodi/jellyfin/connection_manager.py @@ -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, diff --git a/jellyfin_kodi/jellyfin/credentials.py b/jellyfin_kodi/jellyfin/credentials.py index 4e28e2c4..711863de 100644 --- a/jellyfin_kodi/jellyfin/credentials.py +++ b/jellyfin_kodi/jellyfin/credentials.py @@ -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__) ################################################################################################# diff --git a/jellyfin_kodi/jellyfin/http.py b/jellyfin_kodi/jellyfin/http.py index be022420..f5f7178b 100644 --- a/jellyfin_kodi/jellyfin/http.py +++ b/jellyfin_kodi/jellyfin/http.py @@ -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__) ################################################################################################# @@ -222,7 +222,7 @@ class HTTP(object): data['headers'].update({'x-emby-authorization': auth}) if self.config.data.get('auth.token') and self.config.data.get('auth.user_id'): - + auth += ', UserId=%s' % self.config.data.get('auth.user_id') data['headers'].update({'x-emby-authorization': auth, 'X-MediaBrowser-Token': self.config.data.get('auth.token')}) diff --git a/jellyfin_kodi/jellyfin/ws_client.py b/jellyfin_kodi/jellyfin/ws_client.py index da2efcbf..177644b7 100644 --- a/jellyfin_kodi/jellyfin/ws_client.py +++ b/jellyfin_kodi/jellyfin/ws_client.py @@ -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__) ################################################################################################## diff --git a/jellyfin_kodi/library.py b/jellyfin_kodi/library.py index bd55fd43..90cc01cf 100644 --- a/jellyfin_kodi/library.py +++ b/jellyfin_kodi/library.py @@ -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) diff --git a/jellyfin_kodi/monitor.py b/jellyfin_kodi/monitor.py index 4adbaef2..bbdbc7c4 100644 --- a/jellyfin_kodi/monitor.py +++ b/jellyfin_kodi/monitor.py @@ -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__) ################################################################################################# diff --git a/jellyfin_kodi/objects/actions.py b/jellyfin_kodi/objects/actions.py index 01d3a857..45b9ede5 100644 --- a/jellyfin_kodi/objects/actions.py +++ b/jellyfin_kodi/objects/actions.py @@ -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__) ################################################################################################# diff --git a/jellyfin_kodi/objects/kodi/artwork.py b/jellyfin_kodi/objects/kodi/artwork.py index b68401c1..e4847a12 100644 --- a/jellyfin_kodi/objects/kodi/artwork.py +++ b/jellyfin_kodi/objects/kodi/artwork.py @@ -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__) ################################################################################################## diff --git a/jellyfin_kodi/objects/kodi/kodi.py b/jellyfin_kodi/objects/kodi/kodi.py index 924f3c13..ff567bf1 100644 --- a/jellyfin_kodi/objects/kodi/kodi.py +++ b/jellyfin_kodi/objects/kodi/kodi.py @@ -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__) ################################################################################################## diff --git a/jellyfin_kodi/objects/kodi/movies.py b/jellyfin_kodi/objects/kodi/movies.py index 0515f2e0..5d3dfb28 100644 --- a/jellyfin_kodi/objects/kodi/movies.py +++ b/jellyfin_kodi/objects/kodi/movies.py @@ -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__) ################################################################################################## diff --git a/jellyfin_kodi/objects/kodi/music.py b/jellyfin_kodi/objects/kodi/music.py index 89213e94..473f3523 100644 --- a/jellyfin_kodi/objects/kodi/music.py +++ b/jellyfin_kodi/objects/kodi/music.py @@ -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__) ################################################################################################## diff --git a/jellyfin_kodi/objects/kodi/musicvideos.py b/jellyfin_kodi/objects/kodi/musicvideos.py index 70de6cdf..14752a52 100644 --- a/jellyfin_kodi/objects/kodi/musicvideos.py +++ b/jellyfin_kodi/objects/kodi/musicvideos.py @@ -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__) ################################################################################################## diff --git a/jellyfin_kodi/objects/kodi/tvshows.py b/jellyfin_kodi/objects/kodi/tvshows.py index b9feda4d..81f1e4bf 100644 --- a/jellyfin_kodi/objects/kodi/tvshows.py +++ b/jellyfin_kodi/objects/kodi/tvshows.py @@ -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__) ################################################################################################## diff --git a/jellyfin_kodi/objects/movies.py b/jellyfin_kodi/objects/movies.py index 826c5f08..e74c7f70 100644 --- a/jellyfin_kodi/objects/movies.py +++ b/jellyfin_kodi/objects/movies.py @@ -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__) ################################################################################################## diff --git a/jellyfin_kodi/objects/music.py b/jellyfin_kodi/objects/music.py index 1dff5387..fa4080e3 100644 --- a/jellyfin_kodi/objects/music.py +++ b/jellyfin_kodi/objects/music.py @@ -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__) ################################################################################################## diff --git a/jellyfin_kodi/objects/musicvideos.py b/jellyfin_kodi/objects/musicvideos.py index e6c8aa82..4f4ceb41 100644 --- a/jellyfin_kodi/objects/musicvideos.py +++ b/jellyfin_kodi/objects/musicvideos.py @@ -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__) ################################################################################################## diff --git a/jellyfin_kodi/objects/obj.py b/jellyfin_kodi/objects/obj.py index 1cca13e4..0d6da07c 100644 --- a/jellyfin_kodi/objects/obj.py +++ b/jellyfin_kodi/objects/obj.py @@ -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__) ################################################################################################## diff --git a/jellyfin_kodi/objects/tvshows.py b/jellyfin_kodi/objects/tvshows.py index e8442bc9..7980e351 100644 --- a/jellyfin_kodi/objects/tvshows.py +++ b/jellyfin_kodi/objects/tvshows.py @@ -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__) ################################################################################################## diff --git a/jellyfin_kodi/objects/utils.py b/jellyfin_kodi/objects/utils.py index cbed4e74..56f5876a 100644 --- a/jellyfin_kodi/objects/utils.py +++ b/jellyfin_kodi/objects/utils.py @@ -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__) ################################################################################################# diff --git a/jellyfin_kodi/player.py b/jellyfin_kodi/player.py index cd758fb1..3a5754e4 100644 --- a/jellyfin_kodi/player.py +++ b/jellyfin_kodi/player.py @@ -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__) ################################################################################################# diff --git a/jellyfin_kodi/views.py b/jellyfin_kodi/views.py index eccba331..74504ebf 100644 --- a/jellyfin_kodi/views.py +++ b/jellyfin_kodi/views.py @@ -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), diff --git a/jellyfin_kodi/webservice.py b/jellyfin_kodi/webservice.py index db63a07a..4cb199eb 100644 --- a/jellyfin_kodi/webservice.py +++ b/jellyfin_kodi/webservice.py @@ -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__) ################################################################################################# diff --git a/service.py b/service.py index a1951880..30790e63 100644 --- a/service.py +++ b/service.py @@ -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("service") DELAY = int(settings('startupDelay') if settings('SyncInstallRunDone.bool') else 4 or 0) ################################################################################################# From 6c5ac6292d4763be489c65499e157a6783ac20cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odd=20Str=C3=A5b=C3=B8?= Date: Sun, 19 Apr 2020 04:37:58 +0200 Subject: [PATCH 2/3] Overwriting `logging.Formatter._fmt` seems to no longer work in Python 3 --- jellyfin_kodi/helper/loghandler.py | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/jellyfin_kodi/helper/loghandler.py b/jellyfin_kodi/helper/loghandler.py index 2d3ec659..0e8fabc7 100644 --- a/jellyfin_kodi/helper/loghandler.py +++ b/jellyfin_kodi/helper/loghandler.py @@ -61,10 +61,7 @@ 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) + xbmc.log(string, level=xbmc.LOGNOTICE) @classmethod def _get_log_level(cls, level): @@ -85,27 +82,15 @@ class LogHandler(logging.StreamHandler): 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): From 0ba319e7009ee2612c18d6c0adecfa8554cecb9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odd=20Str=C3=A5b=C3=B8?= Date: Sun, 19 Apr 2020 06:13:25 +0200 Subject: [PATCH 3/3] Use __name__ for all logger names --- context.py | 2 +- context_play.py | 2 +- default.py | 2 +- jellyfin_kodi/entrypoint/__init__.py | 2 +- service.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/context.py b/context.py index c3cba508..35655d7d 100644 --- a/context.py +++ b/context.py @@ -22,7 +22,7 @@ from helper import LazyLogger # noqa: F402 ################################################################################################# -LOG = LazyLogger("context") +LOG = LazyLogger(__name__) ################################################################################################# diff --git a/context_play.py b/context_play.py index 48e3cc15..2788a23d 100644 --- a/context_play.py +++ b/context_play.py @@ -22,7 +22,7 @@ from helper import LazyLogger # noqa: F402 ################################################################################################# -LOG = LazyLogger("context_play") +LOG = LazyLogger(__name__) ################################################################################################# diff --git a/default.py b/default.py index 210bf991..a4eb60c4 100644 --- a/default.py +++ b/default.py @@ -22,7 +22,7 @@ from helper import LazyLogger # noqa: F402 ################################################################################################# -LOG = LazyLogger("default") +LOG = LazyLogger(__name__) ################################################################################################# diff --git a/jellyfin_kodi/entrypoint/__init__.py b/jellyfin_kodi/entrypoint/__init__.py index ebb84487..84a9e4b4 100644 --- a/jellyfin_kodi/entrypoint/__init__.py +++ b/jellyfin_kodi/entrypoint/__init__.py @@ -16,6 +16,6 @@ from .context import Context ################################################################################################# -LOG = LazyLogger("entrypoint") +LOG = LazyLogger(__name__) ################################################################################################# diff --git a/service.py b/service.py index 30790e63..5b8447a1 100644 --- a/service.py +++ b/service.py @@ -24,7 +24,7 @@ from helper import LazyLogger # noqa: F402 ################################################################################################# -LOG = LazyLogger("service") +LOG = LazyLogger(__name__) DELAY = int(settings('startupDelay') if settings('SyncInstallRunDone.bool') else 4 or 0) #################################################################################################