espnet3.utils.logging_utils.set_stage_log_handler
Less than 1 minute
espnet3.utils.logging_utils.set_stage_log_handler
espnet3.utils.logging_utils.set_stage_log_handler(log_dir: Path | None, filename: str) → Path | None
Attach a file handler for a stage log, replacing any prior stage handler.
This function adds a new file handler to the root logger and removes any previously installed stage handler (identified via _espnet3_stage_log). If a log file already exists at the target path, it is rotated (e.g., train.log -> train1.log) before creating the new handler.
- Parameters:
- logger (logging.Logger) – Logger used to emit logs. The handler is attached to the root logger so the logger hierarchy continues to work as expected.
- log_dir (Path | None) – Directory that should receive the stage log. If None, no handler is installed and None is returned.
- filename (str) – Log filename to create within
log_dir.
- Returns: Resolved log file path when installed, otherwise None.
- Return type: Path | None
