logging_config
logging_config
Structured logging configuration for the emissions pipeline.
Provides centralized logging configuration with consistent formatting across all modules.
Usage: from validere.logging_config import configure_logging, get_logger
# In main script or entry point
configure_logging(level=logging.INFO)
# In any module
logger = get_logger(__name__)
logger.info("Processing started")
logger.warning("Missing data for facility %s", facility_id)
logger.error("Failed to process file: %s", error_msg)
Functions
| Name | Description |
|---|---|
| configure_logging | Configure logging for entire application. |
| get_logger | Get logger instance for a module. |
| log_dataframe_info | Log information about a DataFrame (shape, memory usage). |
| log_step | Log a processing step with consistent formatting. |
| set_level | Change logging level for all loggers. |
configure_logging
logging_config.configure_logging(
level: int = logging.INFO,
log_file: Path | str | None = None,
format_string: str | None = None,
include_timestamp: bool = True,
)Configure logging for entire application.
Args: level: Logging level log_file: Optional file path for log output format_string: Custom log format (uses default if None) include_timestamp: Whether to include timestamps
get_logger
logging_config.get_logger(name: str)Get logger instance for a module.
Args: name: Logger name (typically name)
log_dataframe_info
logging_config.log_dataframe_info(
logger: logging.Logger,
df,
name: str = 'DataFrame',
)Log information about a DataFrame (shape, memory usage).
Args: logger: Logger instance df: pandas DataFrame name: Name to use in log message
Example: >>> logger = get_logger(name) >>> log_dataframe_info(logger, df, “Production Data”)
log_step
logging_config.log_step(
logger: logging.Logger,
step: int,
total: int,
description: str,
)Log a processing step with consistent formatting.
Args: logger: Logger instance step: Current step number (1-indexed) total: Total number of steps description: Step description
Example: >>> logger = get_logger(name) >>> log_step(logger, 1, 5, “Loading bronze data”)
set_level
logging_config.set_level(level: int)Change logging level for all loggers.