🐛fix(project): add logger on errors in cli module
This commit is contained in:
@@ -43,6 +43,7 @@ def _is_log_file(path: Path) -> bool:
|
|||||||
|
|
||||||
def _get_files_from_dir(input_dir: Path) -> list[Path]:
|
def _get_files_from_dir(input_dir: Path) -> list[Path]:
|
||||||
if not input_dir.exists():
|
if not input_dir.exists():
|
||||||
|
logger.error(f"Unrecognized input directory '{input_dir}'.")
|
||||||
raise FileNotFoundError(f"No such directory at '{input_dir}'")
|
raise FileNotFoundError(f"No such directory at '{input_dir}'")
|
||||||
return [file for file in input_dir.iterdir() if _is_log_file(file)]
|
return [file for file in input_dir.iterdir() if _is_log_file(file)]
|
||||||
|
|
||||||
@@ -51,6 +52,7 @@ def _files_to_log_entries(input_files: list[Path]) -> list[LogEntry]:
|
|||||||
log_entries = []
|
log_entries = []
|
||||||
for file in input_files:
|
for file in input_files:
|
||||||
if not file.is_file():
|
if not file.is_file():
|
||||||
|
logger.error(f"Unrecognized input file '{file}'.")
|
||||||
raise ValueError(f"'{file}' is not a file")
|
raise ValueError(f"'{file}' is not a file")
|
||||||
log_entries.extend(parse_log_file(file))
|
log_entries.extend(parse_log_file(file))
|
||||||
return log_entries
|
return log_entries
|
||||||
@@ -110,6 +112,7 @@ def cli(
|
|||||||
logger.info(f"input_dir option selected with value {input_dir}")
|
logger.info(f"input_dir option selected with value {input_dir}")
|
||||||
log_files = _get_files_from_dir(input_dir)
|
log_files = _get_files_from_dir(input_dir)
|
||||||
else:
|
else:
|
||||||
|
logger.error("Neither input-files nor input-dir were provided.")
|
||||||
raise typer.BadParameter("Either input_files or input_dir must be provided")
|
raise typer.BadParameter("Either input_files or input_dir must be provided")
|
||||||
|
|
||||||
logger.info(f"reports will be located at '{output_dir.cwd()}'")
|
logger.info(f"reports will be located at '{output_dir.cwd()}'")
|
||||||
|
|||||||
Reference in New Issue
Block a user