diff --git a/src/sysdiagnose/analysers/demo_analyser.py b/src/sysdiagnose/analysers/demo_analyser.py index 6872728..a624461 100644 --- a/src/sysdiagnose/analysers/demo_analyser.py +++ b/src/sysdiagnose/analysers/demo_analyser.py @@ -20,10 +20,17 @@ def execute(self): Load parsers here, and use the parser.get_result() to get the data. By doing so you will get the parser output even if it never ran before. """ - print("DO SOMETHING HERE") - logger.info("log something here", extra={'analyser': __name__}) - - # json_data = p_fooparser.get_result() + try: + print("DO SOMETHING HERE") + logger.info("log something here", extra={'analyser': __name__}) + if True: + logger.warning("This will log a warning") + # logger.error("This will log an error") + + # json_data = p_fooparser.get_result() + except Exception as e: + logger.exception("This will log an error with the exception information") + # logger.warning("This will log a warning with the exception information", exc_info=True) result = {'foo': 'bar'} return result diff --git a/src/sysdiagnose/parsers/demo_parser.py b/src/sysdiagnose/parsers/demo_parser.py index 74610e3..a72b412 100644 --- a/src/sysdiagnose/parsers/demo_parser.py +++ b/src/sysdiagnose/parsers/demo_parser.py @@ -26,11 +26,16 @@ def execute(self) -> list | dict: log_files = self.get_log_files() for log_file in log_files: entry = {} - - # timestamp = datetime.strptime(item['timestamp'], '%Y-%m-%d %H:%M:%S.%f %z') - # entry['datetime'] = timestamp.isoformat(timespec='microseconds') - # entry['timestamp'] = timestamp.timestamp() - result.append(entry) - logger.info(f"Processing file {log_file}, new entry added", extra={'log_file': log_file, 'entry': entry}) - + try: + # timestamp = datetime.strptime(item['timestamp'], '%Y-%m-%d %H:%M:%S.%f %z') + # entry['datetime'] = timestamp.isoformat(timespec='microseconds') + # entry['timestamp'] = timestamp.timestamp() + result.append(entry) + logger.info(f"Processing file {log_file}, new entry added", extra={'log_file': log_file, 'entry': entry}) + if not entry: + logger.warning("Empty entry.") + # logger.error("Empty entry.") + except Exception as e: + logger.exception("This will log an error with the exception information") + # logger.warning("This will log a warning with the exception information", exc_info=True) return result