Skip to content

Commit

Permalink
#11 adding logging to:
Browse files Browse the repository at this point in the history
1. another demo parser??
2. get_result method when using cached results
  • Loading branch information
dario-br committed Oct 14, 2024
1 parent 2a285ef commit b4bd4ef
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/sysdiagnose/parsers/demo_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import os
import json
from sysdiagnose.utils.base import BaseParserInterface
import logging

logger = logging.getLogger(__name__)


class DemoParser(BaseParserInterface):
Expand All @@ -25,6 +28,7 @@ def execute(self) -> list | dict:
json_object = {}
log_files = self.get_log_files()
for log_file in log_files:
logger.info(f"Processing file {log_file}")
pass
return json_object

Expand All @@ -44,5 +48,5 @@ def parse_path_to_folder(self, path: str, output_folder: str) -> bool:
json.dump(json_object, f)
return True
except Exception as e:
print(f"Error: {e}")
logger.error(f"Error: {e}")
return False
1 change: 1 addition & 0 deletions src/sysdiagnose/utils/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def get_result(self, force: bool = False) -> list | dict:

if self._result is None:
if self.output_exists():
logger.info("Using cached results")
# load existing output
with open(self.output_file, 'r') as f:
if self.format == 'json':
Expand Down

0 comments on commit b4bd4ef

Please sign in to comment.