From 09a2e95515ac59d4f7ab5ca1f8d12e0a68d790b8 Mon Sep 17 00:00:00 2001 From: Igor Katkov Date: Tue, 30 Dec 2025 10:15:37 -0800 Subject: [PATCH] fix: Root logger aligns with config.LOGLEVEL --- app/main.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index 57b7c32..a70f0b8 100644 --- a/app/main.py +++ b/app/main.py @@ -37,7 +37,9 @@ def parseLogLevel(logLevel): return None # Configure logging before Config() uses it so early messages are not dropped. -logging.basicConfig(level=parseLogLevel(os.environ.get('LOGLEVEL', 'INFO')) or logging.INFO) +# Only configure if no handlers are set (avoid clobbering hosting app settings). +if not logging.getLogger().hasHandlers(): + logging.basicConfig(level=parseLogLevel(os.environ.get('LOGLEVEL', 'INFO')) or logging.INFO) class Config: _DEFAULTS = { @@ -130,6 +132,10 @@ class Config: return (True, '') config = Config() +# Align root logger level with Config (keeps a single source of truth). +# This re-applies the log level after Config loads, in case LOGLEVEL was +# overridden by config file settings or differs from the environment variable. +logging.getLogger().setLevel(parseLogLevel(str(config.LOGLEVEL)) or logging.INFO) class ObjectSerializer(json.JSONEncoder): def default(self, obj):