From 0d840f3d61320b3fdea32dbd7e2093d9335963e3 Mon Sep 17 00:00:00 2001 From: Jennifer Power Date: Fri, 22 Mar 2024 20:21:39 -0400 Subject: [PATCH] chore: adds additional logging messages around model processing Signed-off-by: Jennifer Power --- trestlebot/tasks/assemble_task.py | 5 +++++ trestlebot/tasks/regenerate_task.py | 5 +++++ trestlebot/tasks/rule_transform_task.py | 3 ++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/trestlebot/tasks/assemble_task.py b/trestlebot/tasks/assemble_task.py index fca1f915..1c755837 100644 --- a/trestlebot/tasks/assemble_task.py +++ b/trestlebot/tasks/assemble_task.py @@ -4,6 +4,7 @@ """Trestle Bot Assembly Tasks""" +import logging import os import pathlib from typing import Optional @@ -16,6 +17,9 @@ from trestlebot.tasks.base_task import ModelFilter, TaskBase, TaskException +logger = logging.getLogger(__name__) + + class AssembleTask(TaskBase): """ Assemble Markdown into OSCAL content @@ -62,6 +66,7 @@ def _assemble(self) -> int: for model in self.iterate_models(pathlib.Path(search_path)): # Construct model path from markdown path. AuthoredObject already has # the working dir data as part of object construction. + logger.info(f"Assembling model {model}") model_base_name = os.path.basename(model) model_path = os.path.join(self._markdown_dir, model_base_name) try: diff --git a/trestlebot/tasks/regenerate_task.py b/trestlebot/tasks/regenerate_task.py index 8b05cb36..ed9ab836 100644 --- a/trestlebot/tasks/regenerate_task.py +++ b/trestlebot/tasks/regenerate_task.py @@ -4,6 +4,7 @@ """Trestle Bot Regenerate Tasks""" +import logging import os import pathlib from typing import Optional @@ -17,6 +18,9 @@ from trestlebot.tasks.base_task import ModelFilter, TaskBase, TaskException +logger = logging.getLogger(__name__) + + class RegenerateTask(TaskBase): """ Regenerate Trestle Markdown from OSCAL JSON content changes @@ -58,6 +62,7 @@ def _regenerate(self) -> int: search_path = os.path.join(self.working_dir, model_dir) for model in self.iterate_models(pathlib.Path(search_path)): + logger.info(f"Regenerating model {model}") model_base_name = os.path.basename(model) model_path = os.path.join(model_dir, model_base_name) diff --git a/trestlebot/tasks/rule_transform_task.py b/trestlebot/tasks/rule_transform_task.py index a69663a6..3f25d372 100644 --- a/trestlebot/tasks/rule_transform_task.py +++ b/trestlebot/tasks/rule_transform_task.py @@ -79,7 +79,7 @@ def _transform(self) -> int: def _transform_components(self, component_definition_path: pathlib.Path) -> None: """Transform components into an OSCAL component definition.""" csv_builder: CSVBuilder = CSVBuilder() - logger.debug( + logger.info( f"Transforming rules for component definition {component_definition_path.name}" ) @@ -87,6 +87,7 @@ def _transform_components(self, component_definition_path: pathlib.Path) -> None # pretty print them in a raised exception transformation_errors: List[str] = [] for component in self.iterate_models(component_definition_path): + logger.debug(f"Transforming rules for component {component.name}") for rule_path in self.iterate_models(component): # Load the rule into memory as a stream to process rule_stream = rule_path.read_text()