logging#

Helpers for configuring logging and recording raw process results.

Functions

log_build_test_result(result[, kernel_uuid, ...])

Log all raw subprocess outputs contained in a build or test result.

log_process_result(name, result, ...[, ...])

Log stdout, stderr, and metadata for a single process execution.

setup_logging(logfile[, logging_level])

Configure the root logger with a file handler and custom RAW level.

kernelfoundry.algorithm.utils.logging.log_process_result(name: str, result: ProcessResult, kernel_uuid: str, iteration: int, branch: int, worker_info: dict | None = None, agent_session_id: str | None = None) → None[source]#

Log stdout, stderr, and metadata for a single process execution.

Parameters:
  • name – Event name emitted through the custom RAW logging level.

  • result – Process result containing return code, streams, and optional metadata.

  • kernel_uuid – Unique identifier for the kernel associated with this result.

  • iteration – Iteration identifier recorded alongside the raw log payload.

  • branch – Branch value recorded alongside the raw log payload.

  • worker_info – Optional worker metadata to include in the structured log payload.

  • agent_session_id – Optional agent session identifier to include in the structured log payload.

kernelfoundry.algorithm.utils.logging.log_build_test_result(result: BuildResult | TestResult, kernel_uuid: str | None = None, agent_session_id: str | None = None, iteration: int | None = None, branch: int | None = None, prefix: str | None = None) → None[source]#

Log all raw subprocess outputs contained in a build or test result.

Parameters:
  • result – Build or test result whose subprocess outputs should be emitted.

  • kernel_uuid – Unique identifier for the kernel associated with this result.

  • iteration – Iteration recorded alongside each emitted raw log payload.

  • branch – Branch (formerly version) recorded alongside each emitted raw log payload.

  • prefix – Optional prefix used to name emitted log events. Defaults to build or test based on the result type.

kernelfoundry.algorithm.utils.logging.setup_logging(logfile: str | Path, logging_level=None)[source]#

Configure the root logger with a file handler and custom RAW level.

Parameters:
  • logfile – Path to the log file that should receive root logger output. This is usually a path to the “controller.log” in the respective run directory.

  • logging_level – Logging level to apply to the file handler and root logger. If None, the current root logger level is reused.