logger
orchard.core.logger
¶
Telemetry and Reporting Package.
This package centralizes experiment logging, environment reporting, and visual telemetry. It provides high-level utilities to initialize system-wide loggers and format experiment metadata for reproducibility.
Available Components:
- Logger: Static utility for stream and file logging initialization.
- Reporter: Metadata reporting engine for environment baseline status.
- LogStyle: Unified logging style constants.
- Progress functions: Optimization and training progress logging.
LogStyle
¶
Unified logging style constants for consistent visual hierarchy.
Provides separators, symbols, indentation, and ANSI color codes used
by all logging modules. Placed here (in paths.constants) rather
than in logger.styles so that low-level packages (environment,
config) can reference the constants without triggering circular
imports.
Reporter
¶
Bases: BaseModel
Centralized logging and reporting utility for experiment lifecycle events.
Transforms complex configuration states and hardware objects into human-readable logs. Called by Orchestrator during initialization.
log_phase_header(log, title, style=None)
staticmethod
¶
Log a centered phase header with separator lines.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log
|
Logger
|
Logger instance to write to. |
required |
title
|
str
|
Header text (will be uppercased and centered). |
required |
style
|
str | None
|
Separator string (defaults to |
None
|
Source code in orchard/core/logger/env_reporter.py
log_initial_status(logger_instance, cfg, paths, device, applied_threads, num_workers)
¶
Logs verified baseline environment configuration upon initialization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
logger_instance
|
Logger
|
Active experiment logger |
required |
cfg
|
'Config'
|
Validated global configuration manifest |
required |
paths
|
'RunPaths'
|
Dynamic path orchestrator for current session |
required |
device
|
'torch.device'
|
Resolved PyTorch compute device |
required |
applied_threads
|
int
|
Number of intra-op threads assigned |
required |
num_workers
|
int
|
Number of DataLoader workers |
required |
Source code in orchard/core/logger/env_reporter.py
ReporterProtocol
¶
Bases: Protocol
Protocol for environment reporting, allowing mocking in tests.
log_initial_status(logger_instance, cfg, paths, device, applied_threads, num_workers)
¶
Logs the initial status of the environment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
logger_instance
|
Logger
|
The logger instance used to log the status. |
required |
cfg
|
'Config'
|
The configuration object containing environment settings. |
required |
paths
|
'RunPaths'
|
The paths object with directories for the run. |
required |
device
|
device
|
The device (e.g., CPU or GPU) to be used for processing. |
required |
applied_threads
|
int
|
The number of threads allocated for processing. |
required |
num_workers
|
int
|
The number of worker processes to use. |
required |
Source code in orchard/core/logger/env_reporter.py
Logger(name=LOGGER_NAME, log_dir=None, log_to_file=True, level=logging.INFO, max_bytes=5 * 1024 * 1024, backup_count=5)
¶
Manages centralized logging configuration with singleton-like behavior.
Provides a unified logging interface for the entire framework with support for dynamic reconfiguration. Initially bootstraps with console-only output, then transitions to dual console+file logging when experiment directories become available.
The logger implements pseudo-singleton semantics via class-level tracking (_configured_names) to prevent duplicate handler registration while allowing intentional reconfiguration when log directories are provided.
Lifecycle
- Bootstrap Phase: Console-only logging (no log_dir specified)
- Orchestration Phase: RootOrchestrator calls setup() with log_dir
- Reconfiguration: Existing handlers removed, file handler added
Class Attributes: _configured_names (dict[str, bool]): Tracks which logger names have been configured
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Logger identifier (typically LOGGER_NAME constant) |
log_dir |
Path | None
|
Directory for log file storage |
log_to_file |
bool
|
Enable file logging (requires log_dir) |
level |
int
|
Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL) |
max_bytes |
int
|
Maximum log file size before rotation (default: 5MB) |
backup_count |
int
|
Number of rotated log files to retain (default: 5) |
_log |
Logger
|
Underlying Python logger instance |
Example
Bootstrap phase (console-only)¶
logger = Logger().get_logger() logger.info("Framework initializing...")
Orchestration phase (add file logging)¶
logger = Logger.setup( ... name=LOGGER_NAME, ... log_dir=Path("./outputs/run_123/logs"), ... level="INFO" ... ) logger.info("Logging to file now")
Notes:
- Reconfiguration is idempotent: calling setup() multiple times is safe
- All handlers are properly closed before reconfiguration
- Log files use UTC timestamps for consistency across time zones
- RotatingFileHandler prevents disk space exhaustion
Initializes the Logger with specified configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Logger identifier (default: LOGGER_NAME constant) |
LOGGER_NAME
|
log_dir
|
Path | None
|
Directory for log file storage (None = console-only) |
None
|
log_to_file
|
bool
|
Enable file logging if log_dir provided (default: True) |
True
|
level
|
int
|
Logging level as integer constant (default: logging.INFO) |
INFO
|
max_bytes
|
int
|
Maximum log file size before rotation in bytes (default: 5MB) |
5 * 1024 * 1024
|
backup_count
|
int
|
Number of rotated backup files to retain (default: 5) |
5
|
Source code in orchard/core/logger/logger.py
get_logger()
¶
Returns the configured logging.Logger instance.
Returns:
| Type | Description |
|---|---|
Logger
|
The underlying Python logging.Logger instance with configured handlers |
setup(name, log_dir=None, level='INFO', **kwargs)
classmethod
¶
Main entry point for configuring the logger, called by RootOrchestrator.
Bridges semantic LogLevel strings (INFO, DEBUG, WARNING) to Python logging constants. Provides convenient string-based level specification while internally using numeric logging constants.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Logger identifier (typically LOGGER_NAME constant) |
required |
log_dir
|
Path | None
|
Directory for log file storage (None = console-only mode) |
None
|
level
|
str
|
Logging level as string (DEBUG, INFO, WARNING, ERROR, CRITICAL) |
'INFO'
|
**kwargs
|
Any
|
Additional arguments passed to Logger constructor |
{}
|
Returns:
| Type | Description |
|---|---|
Logger
|
Configured logging.Logger instance ready for use |
Environment Variables
DEBUG: If set to "1", overrides level to DEBUG regardless of level parameter
Example
logger = Logger.setup( ... name="OrchardML", ... log_dir=Path("./outputs/run_123/logs"), ... level="INFO" ... ) logger.info("Training started")
Source code in orchard/core/logger/logger.py
log_optimization_header(cfg, logger_instance=None)
¶
Log Optuna optimization configuration details.
Logs search-specific parameters only (dataset/model already shown in environment).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cfg
|
'Config'
|
Configuration with optuna settings |
required |
logger_instance
|
Logger | None
|
Logger instance to use (defaults to module logger) |
None
|
Source code in orchard/core/logger/progress.py
log_optimization_summary(study, cfg, device, paths, logger_instance=None)
¶
Log optimization study completion summary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
study
|
'optuna.Study'
|
Completed Optuna study |
required |
cfg
|
'Config'
|
Configuration object |
required |
device
|
'torch.device'
|
PyTorch device used |
required |
paths
|
'RunPaths'
|
Run paths for artifacts |
required |
logger_instance
|
Logger | None
|
Logger instance to use (defaults to module logger) |
None
|
Source code in orchard/core/logger/progress.py
log_pipeline_summary(test_acc, macro_f1, best_model_path, run_dir, duration, test_auc=None, onnx_path=None, logger_instance=None)
¶
Log final pipeline completion summary.
Called at the end of the pipeline after all phases complete. Consolidates key metrics and artifact locations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
test_acc
|
float
|
Final test accuracy |
required |
macro_f1
|
float
|
Final macro F1 score |
required |
best_model_path
|
Path
|
Path to best model checkpoint |
required |
run_dir
|
Path
|
Root directory for this run |
required |
duration
|
str
|
Human-readable duration string |
required |
test_auc
|
float | None
|
Final test AUC (if available) |
None
|
onnx_path
|
Path | None
|
Path to ONNX export (if performed) |
None
|
logger_instance
|
Logger | None
|
Logger instance to use (defaults to module logger) |
None
|
Source code in orchard/core/logger/progress.py
log_trial_start(trial_number, params, logger_instance=None)
¶
Log trial start with formatted parameters (grouped by category).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trial_number
|
int
|
Trial index |
required |
params
|
dict[str, Any]
|
Sampled hyperparameters |
required |
logger_instance
|
Logger | None
|
Logger instance to use (defaults to module logger) |
None
|