Logging configuration for metahq-build.

Provides structured logging with multiple handlers for console and file output. Supports different log levels and formatting options.

PipelineLogger

Specialized logger for pipeline execution with stage tracking.

Provides methods for logging pipeline-specific events like stage transitions, progress updates, and data statistics.

Attributes:
  • logger (Logger) –

    Underlying logger instance

  • current_stage (str | None) –

    Name of the current pipeline stage

Examples:

>>> pipeline_logger = PipelineLogger("metahq_build.pipeline")
>>> pipeline_logger.start_stage("fetch_metadata")
>>> pipeline_logger.log_stat("Fetched samples", 1500)
>>> pipeline_logger.end_stage("fetch_metadata")

start_stage(stage_name)

Log the start of a pipeline stage.

Parameters:
  • stage_name (str) –

    Name of the pipeline stage

end_stage(stage_name)

Log the completion of a pipeline stage.

Parameters:
  • stage_name (str) –

    Name of the pipeline stage

log_stat(description, value)

Log a statistic with description and value.

Parameters:
  • description (str) –

    Description of the statistic

  • value (int | float | str) –

    Value of the statistic

log_progress(message)

Log a progress message within a stage.

Parameters:
  • message (str) –

    Progress message to log

log_error(message, exc_info=False)

Log an error message.

Parameters:
  • message (str) –

    Error message to log

  • exc_info (bool, default: False ) –

    Whether to include exception traceback

log_warning(message)

Log a warning message.

Parameters:
  • message (str) –

    Warning message to log

log_debug(message)

Log a debug message.

Parameters:
  • message (str) –

    Debug message to log

setup_logger(name, level=logging.INFO, log_file=None, use_rich=True)

Configure and return a logger with console and optional file handlers.

Parameters:
  • name (str) –

    Name of the logger (typically name)

  • level (int, default: INFO ) –

    Logging level (e.g., logging.INFO, logging.DEBUG)

  • log_file (Path | None, default: None ) –

    Path to log file. If None, no file handler is added

  • use_rich (bool, default: True ) –

    Whether to use rich console handler for colored output

Returns:
  • Logger

    Configured logger instance

Examples:

>>> logger = setup_logger(__name__, level=logging.DEBUG)
>>> logger.info("Processing started")
>>> logger.warning("Missing data for sample GSM123")

get_default_log_file(package_root)

Get default log file path for the package.

Parameters:
  • package_root (Path) –

    Root directory of the metahq_build package

Returns:
  • Path

    Path to default log file in .log directory