@@ -45,9 +45,10 @@ def _read_with_journalctl(self):
4545 Returns:
4646 str|None: system journal read
4747 """
48- cmd = "journalctl --no-pager --system --all --output=json "
48+ cmd = "journalctl --no-pager --system --all --output=short-iso "
4949 res = self ._run_sut_cmd (cmd , sudo = True , log_artifact = False , strip = False )
5050
51+
5152 if res .exit_code != 0 :
5253 self ._log_event (
5354 category = EventCategory .OS ,
@@ -60,21 +61,22 @@ def _read_with_journalctl(self):
6061 self .result .status = ExecutionStatus .ERROR
6162 return None
6263
63- raw = res .stdout
64- text = (
65- raw .decode ("utf-8" , errors = "surrogateescape" )
66- if isinstance (raw , (bytes , bytearray ))
67- else raw
68- )
64+ out = res .stdout
65+
66+ if isinstance (out , (bytes , bytearray )):
67+ try :
68+ text = out .decode ("utf-8" )
69+ except UnicodeDecodeError :
70+ text = out .decode ("utf-8" , errors = "replace" )
71+ else :
72+ text = out
6973
70- lines = [ln for ln in (line .strip () for line in text .splitlines ()) if ln .startswith ("{" )]
71- array_like = "[" + "," .join (lines ) + "]"
72- entries : list [dict ] = json .load (io .StringIO (array_like ))
74+ text = text .replace ("\r \n " , "\n " ).replace ("\r " , "\n " ).replace ("\x00 " , "" )
75+ return text
7376
74- return entries
7577
7678 def collect_data (self , args = None ) -> tuple [TaskResult , JournalData | None ]:
77- """Collect journal lofs
79+ """Collect journal logs
7880
7981 Args:
8082 args (_type_, optional): Collection args. Defaults to None.
0 commit comments