diff --git a/fixcloudutils/logging/__init__.py b/fixcloudutils/logging/__init__.py index 96bb218..afb40c7 100644 --- a/fixcloudutils/logging/__init__.py +++ b/fixcloudutils/logging/__init__.py @@ -22,7 +22,7 @@ import logging import os from logging import StreamHandler, basicConfig -from typing import Optional, List, Dict +from typing import Optional, List, Dict, Callable from .json_logger import JsonFormatter from .prometheus_counter import PrometheusLoggingCounter @@ -39,6 +39,7 @@ def setup_logger( count_logs: bool = True, log_format: Optional[str] = None, json_format_dict: Optional[Dict[str, str]] = None, + get_logging_context: Optional[Callable[[], Dict[str, str]]] = None, ) -> List[StreamHandler]: # type: ignore log_level = level or logging.INFO # override log output via env var @@ -53,7 +54,9 @@ def setup_logger( "pid": "process", "thread": "threadName", } - formatter = JsonFormatter(format_dict, static_values={"component": component}) + formatter = JsonFormatter( + format_dict, static_values={"component": component}, get_logging_context=get_logging_context + ) handler.setFormatter(formatter) basicConfig(handlers=[handler], force=force, level=log_level) else: diff --git a/pyproject.toml b/pyproject.toml index 64a5639..f89e124 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "fixcloudutils" -version = "1.9.0" +version = "1.10.0" authors = [{ name = "Some Engineering Inc." }] description = "Utilities for fixcloud." license = { file = "LICENSE" }