Add sub_dir option to format_log_path

This commit is contained in:
2Shirt 2023-08-13 19:36:38 -07:00
parent e7642bdc63
commit b9c4c9c32f
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C

View file

@ -39,16 +39,21 @@ def enable_debug_mode() -> None:
def format_log_path(
log_dir: None | pathlib.Path | str = None,
log_name: None | str = None,
log_dir: pathlib.Path | str | None = None,
log_name: str | None = None,
append: bool = False,
kit: bool = False,
sub_dir: str | None = None,
timestamp: bool = False,
kit: bool = False, tool: bool = False, append: bool = False,
tool: bool = False,
) -> pathlib.Path:
"""Format path based on args passed, returns pathlib.Path obj."""
log_path = pathlib.Path(
f'{log_dir if log_dir else DEFAULT_LOG_DIR}/'
f'{cfg.main.KIT_NAME_FULL+"/" if kit else ""}'
f'{"Tools/" if tool else ""}'
f'{sub_dir+"_" if sub_dir else ""}'
f'{time.strftime("%Y-%m-%d_%H%M%S%z") if sub_dir else ""}/'
f'{log_name if log_name else DEFAULT_LOG_NAME}'
f'{"_" if timestamp else ""}'
f'{time.strftime("%Y-%m-%d_%H%M%S%z") if timestamp else ""}'
@ -129,7 +134,9 @@ def start(config: dict[str, str] | None = None) -> None:
def update_log_path(
dest_dir: None | pathlib.Path | str = None,
dest_name: None | str = None,
keep_history: bool = True, timestamp: bool = True, append: bool = False,
append: bool = False,
keep_history: bool = True,
timestamp: bool = True,
) -> None:
"""Moves current log file to new path and updates the root logger."""
root_logger = logging.getLogger()