From a4ff545426bb2c903e44b01b25806cd021b70f4d Mon Sep 17 00:00:00 2001 From: Stefaan Lippens Date: Mon, 6 Nov 2023 12:22:36 +0100 Subject: [PATCH] Pass logger to log_version_info --- src/openeo_aggregator/about.py | 7 ++++--- src/openeo_aggregator/app.py | 2 +- src/openeo_aggregator/background/prime_caches.py | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/openeo_aggregator/about.py b/src/openeo_aggregator/about.py index b0b90ae5..f281616f 100644 --- a/src/openeo_aggregator/about.py +++ b/src/openeo_aggregator/about.py @@ -1,9 +1,10 @@ import logging import sys +from typing import Optional __version__ = "0.12.2a1" -def log_version_info(): - log = logging.getLogger(__name__) - log.info(f"openeo-aggregator {__version__} (Python {sys.version}") +def log_version_info(logger: Optional[logging.Logger] = None): + logger = logger or logging.getLogger(__name__) + logger.info(f"openeo-aggregator {__version__} (Python {sys.version})") diff --git a/src/openeo_aggregator/app.py b/src/openeo_aggregator/app.py index b4807e56..364f1035 100644 --- a/src/openeo_aggregator/app.py +++ b/src/openeo_aggregator/app.py @@ -37,7 +37,7 @@ def create_app(config: Any = None, auto_logging_setup: bool = True) -> flask.Fla if auto_logging_setup: setup_logging(config=get_aggregator_logging_config(context=LOGGING_CONTEXT_FLASK)) - log_version_info() + log_version_info(logger=_log) os.environ.setdefault(ConfigGetter.OPENEO_BACKEND_CONFIG, str(get_config_dir() / "backend_config.py")) diff --git a/src/openeo_aggregator/background/prime_caches.py b/src/openeo_aggregator/background/prime_caches.py index 337fdd05..a01d6eab 100644 --- a/src/openeo_aggregator/background/prime_caches.py +++ b/src/openeo_aggregator/background/prime_caches.py @@ -111,7 +111,7 @@ def prime_caches( require_zookeeper_writes: bool = False, fail_mode: str = FAIL_MODE_FAILFAST, ): - log_version_info() + log_version_info(logger=_log) with TimingLogger(title=f"Prime caches", logger=_log): config: AggregatorConfig = get_config(config) _log.info(f"Using config: {config.get('config_source')=}")