jellyfin-kodi/jellyfin_kodi/helper/lazylogger.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

22 lines
594 B
Python
Raw Permalink Normal View History

2020-04-19 01:05:59 +00:00
# -*- coding: utf-8 -*-
from __future__ import division, absolute_import, print_function, unicode_literals
class LazyLogger(object):
"""`helper.loghandler.getLogger()` is used everywhere.
2023-02-07 17:02:24 +00:00
This class helps to avoid import errors.
2020-04-19 01:05:59 +00:00
"""
2024-06-10 09:19:47 +00:00
2020-04-19 01:05:59 +00:00
__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:
2021-10-10 18:38:25 +00:00
from .loghandler import getLogger
2024-06-10 09:19:47 +00:00
2020-04-19 01:05:59 +00:00
self.__logger = getLogger(self.__logger_name)
return getattr(self.__logger, name)