Configure the logging settings for the application. Args: print_level (str): The logging level for console output. logfile_level (str): The logging level for file output.
(
print_level: str = "INFO",
logfile_level: str = "DEBUG",
log_path: Optional[Union[str, Path]] = None,
)
| 6 | from KVCOMM.utils.const import KVCOMM_ROOT |
| 7 | |
| 8 | def configure_logging( |
| 9 | print_level: str = "INFO", |
| 10 | logfile_level: str = "DEBUG", |
| 11 | log_path: Optional[Union[str, Path]] = None, |
| 12 | ) -> None: |
| 13 | """ |
| 14 | Configure the logging settings for the application. |
| 15 | |
| 16 | Args: |
| 17 | print_level (str): The logging level for console output. |
| 18 | logfile_level (str): The logging level for file output. |
| 19 | """ |
| 20 | logger.remove() |
| 21 | logger.add(sys.stderr, level=print_level) |
| 22 | target_path = Path(log_path) if log_path is not None else KVCOMM_ROOT / 'logs/log.txt' |
| 23 | if target_path.is_dir(): |
| 24 | target_path = target_path / "log.txt" |
| 25 | target_path.parent.mkdir(parents=True, exist_ok=True) |
| 26 | logger.add(target_path, level=logfile_level, rotation="10 MB") |
| 27 | |
| 28 | def initialize_log_file(experiment_name: str, time_stamp: str) -> Path: |
| 29 | """ |