Coverage for src/config_logging.py: 100%
20 statements
« prev ^ index » next coverage.py v7.10.7, created at 2025-10-16 04:41 +0000
« prev ^ index » next coverage.py v7.10.7, created at 2025-10-16 04:41 +0000
1"""Logging utilities for configuration-related operations.
3Provides reusable logging functions to separate logging concerns from
4config retrieval logic, following Single Responsibility Principle.
5"""
7__author__ = "Mandar Patil (mandarons@pm.me)"
9from typing import Any
11from src import get_logger
13LOGGER = get_logger()
16def log_config_not_found_warning(config_path: list[str], message: str) -> None:
17 """Log a warning when a config path is not found.
19 Args:
20 config_path: List of config keys forming the path
21 message: Custom warning message to log
22 """
23 from src.config_utils import config_path_to_string
25 path_str = config_path_to_string(config_path)
26 LOGGER.warning(f"{path_str} {message}")
29def log_config_found_info(message: str) -> None:
30 """Log an info message when config value is found and processed.
32 Args:
33 message: Info message to log
34 """
35 LOGGER.info(message)
38def log_config_debug(message: str) -> None:
39 """Log a debug message for config processing.
41 Args:
42 message: Debug message to log
43 """
44 LOGGER.debug(message)
47def log_config_error(config_path: list[str], message: str) -> None:
48 """Log an error for config validation issues.
50 Args:
51 config_path: List of config keys forming the path
52 message: Error message to log
53 """
54 from src.config_utils import config_path_to_string
56 path_str = config_path_to_string(config_path)
57 LOGGER.error(f"{path_str}: {message}")
60def log_invalid_config_value(config_path: list[str], invalid_value: Any, valid_values: str) -> None:
61 """Log warning about invalid config value.
63 Args:
64 config_path: List of config keys forming the path
65 invalid_value: The invalid value that was found
66 valid_values: Description of valid values
67 """
68 from src.config_utils import config_path_to_string
70 path_str = config_path_to_string(config_path)
71 LOGGER.warning(f"Invalid value '{invalid_value}' at {path_str}. Valid values: {valid_values}")