From 8417655b4e2ae18223784500929bc34b9f84604a Mon Sep 17 00:00:00 2001 From: Krzysztof Findeisen Date: Wed, 16 Oct 2024 14:44:21 -0700 Subject: [PATCH] Add a debug logging flag to the service. This makes it possible to change logging levels from the configuration. This commit also replaces the double `logging.basicConfig` calls of the original code; `basicConfig` only has an effect the first time it's called. --- src/main.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main.py b/src/main.py index e2e8f03..20e200e 100644 --- a/src/main.py +++ b/src/main.py @@ -494,8 +494,10 @@ async def main() -> None: security_protocol = os.environ["SECURITY_PROTOCOL"] # Logging config - logging.basicConfig(stream=sys.stdout, level=logging.INFO) - logging.basicConfig(stream=sys.stderr, level=logging.WARNING) + if os.environ.get("DEBUG_LOGS") == "true": + logging.basicConfig(sys.stdout, level=logging.DEBUG) + else: + logging.basicConfig(stream=sys.stdout, level=logging.INFO) conf = yaml.safe_load(Path(instrument_config_file).read_text()) instruments = {inst: InstrumentConfig(conf, inst) for inst in supported_instruments}