Skip to content

Commit

Permalink
chore: adds additional logging messages around model processing
Browse files Browse the repository at this point in the history
Signed-off-by: Jennifer Power <[email protected]>
  • Loading branch information
jpower432 committed Mar 23, 2024
1 parent ff405f6 commit 0d840f3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions trestlebot/tasks/assemble_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

"""Trestle Bot Assembly Tasks"""

import logging
import os
import pathlib
from typing import Optional
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions trestlebot/tasks/regenerate_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

"""Trestle Bot Regenerate Tasks"""

import logging
import os
import pathlib
from typing import Optional
Expand All @@ -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
Expand Down Expand Up @@ -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)

Expand Down
3 changes: 2 additions & 1 deletion trestlebot/tasks/rule_transform_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,15 @@ 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}"
)

# To report all rule errors at once, we collect them in a list and
# 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()
Expand Down

0 comments on commit 0d840f3

Please sign in to comment.