From e4f746cf39b2b6a2b9c67759b720d3be90bc7fa6 Mon Sep 17 00:00:00 2001 From: Marcus Klein Date: Mon, 17 Aug 2026 17:37:57 +0200 Subject: [PATCH] Resolve the standalone log level from ULTIMATE_DEBUG or debug_mode In standalone mode StandardLogger calls setLevel(logging.DEBUG) unconditionally, so neither the ULTIMATE_DEBUG environment variable nor debug_mode in config.json has any effect and every deployment logs at DEBUG. That is a lot of noise for a service that otherwise runs unattended, and it makes the real warnings hard to find in the container log. Resolve the level instead: ULTIMATE_DEBUG first, then debug_mode, defaulting to INFO. The Kodi-addon path is untouched, since Kodi controls the level there. --- lib/streaming_providers/base/utils/logger.py | 31 +++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/lib/streaming_providers/base/utils/logger.py b/lib/streaming_providers/base/utils/logger.py index 67e619c..b26defc 100644 --- a/lib/streaming_providers/base/utils/logger.py +++ b/lib/streaming_providers/base/utils/logger.py @@ -14,6 +14,35 @@ from .environment import get_environment_manager _env_manager_instance = get_environment_manager() +def _resolve_log_level() -> int: + """ + Log level for the standalone logger. + + The environment variable wins, because that is how a container is + configured, then config.json. Anything else defaults to INFO. Level DEBUG + logs every upstream request and response and is written to the log file in + profile_path as well, so it should only be active when it was actually + asked for. + """ + import os + + env_debug = os.environ.get("ULTIMATE_DEBUG") + if env_debug is not None and env_debug.strip() != "": + return ( + logging.DEBUG + if env_debug.strip().lower() in ("1", "true", "yes", "on") + else logging.INFO + ) + + try: + if _env_manager_instance.get_config("debug_mode", False): + return logging.DEBUG + except Exception: # noqa: BLE001 - config is optional, never fail logging setup + pass + + return logging.INFO + + class BaseLogger: """Base logger interface that all logger implementations must follow""" @@ -141,7 +170,7 @@ def create_logger() -> BaseLogger: file=sys.stderr, ) - self._logger.setLevel(logging.DEBUG) + self._logger.setLevel(_resolve_log_level()) def debug(self, message: str) -> None: self._logger.debug(message)