From 5b4f286debe7170076b1398bc76f180acfbe54f8 Mon Sep 17 00:00:00 2001 From: Christophe Vandeplas Date: Tue, 26 Nov 2024 13:14:37 +0100 Subject: [PATCH] fix: [lockdownd] more timezone --- src/sysdiagnose/parsers/lockdownd.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sysdiagnose/parsers/lockdownd.py b/src/sysdiagnose/parsers/lockdownd.py index 701d900..15882d0 100644 --- a/src/sysdiagnose/parsers/lockdownd.py +++ b/src/sysdiagnose/parsers/lockdownd.py @@ -26,11 +26,11 @@ def get_log_files(self) -> list: def execute(self) -> list | dict: for log_file in self.get_log_files(): with open(log_file, 'r') as f: - result = LockdowndParser.extract_from_list(f.readlines()) + result = self.extract_from_list(f.readlines()) return result return [] - def extract_from_list(lines: list) -> list: + def extract_from_list(self, lines: list) -> list: result = [] i = 0 while i < len(lines): @@ -53,7 +53,7 @@ def extract_from_list(lines: list) -> list: # process rebuild current_line match = re.match(r'(^.{24}) pid=(\d+) ([^:]+): (.*)$', current_line, re.DOTALL) timestamp = datetime.strptime(match.group(1), '%m/%d/%y %H:%M:%S.%f') - timestamp = timestamp.replace(tzinfo=timezone.utc) + timestamp = timestamp.replace(tzinfo=self.sysdiagnose_creation_datetime.tzinfo) # LATER parse the json blob that can sometimes be in the message item = { @@ -61,7 +61,7 @@ def extract_from_list(lines: list) -> list: 'datetime': timestamp.isoformat(timespec='microseconds'), 'pid': int(match.group(2)), 'event_type': match.group(3), - 'msg': match.group(4).strip() + 'message': match.group(4).strip() } result.append(item)