Fix text in multiline case

This commit is contained in:
Micke Nordin 2024-09-30 16:43:35 +02:00
parent c26a46e9a4
commit fb89d01be1

View file

@ -99,21 +99,24 @@ def run_audit(url: str, jsonout: bool, headers: dict):
) )
# Simple case, just one line with timestamp # Simple case, just one line with timestamp
if cur_has_timestamp and next_has_timestamp: if cur_has_timestamp and next_has_timestamp:
text = ":". join(line.split(':')[1:])
timestamp = line.split(']')[0].split('[')[1] timestamp = line.split(']')[0].split('[')[1]
text = line.split(']')[1].lstrip(':').strip()
out.append({'timestamp': timestamp, 'text': text}) out.append({'timestamp': timestamp, 'text': text})
text = "" text = ""
timestamp = "" timestamp = ""
# Start of multiline
elif cur_has_timestamp: elif cur_has_timestamp:
timestamp = line.split(']')[0].split('[')[1] timestamp = line.split(']')[0].split('[')[1]
text = ":". join(line.split(':')[1:]) text = line.split(']')[1].lstrip(':').strip()
# End of multiline
elif next_has_timestamp: elif next_has_timestamp:
text += f'\n{line}' text += f'\n{line.strip()}'
out.append({'timestamp': timestamp, 'text': text}) out.append({'timestamp': timestamp, 'text': text})
text = "" text = ""
timestamp = "" timestamp = ""
# Middle of multiline
else: else:
text += f'\n{line}' text += f'\n{line.strip()}'
else: else:
out = string out = string