Skip to content
Snippets Groups Projects
Commit e3bbdfca authored by Michael Eischer's avatar Michael Eischer
Browse files

More resilient client log parsing

Only accept timestamps without leading whitespace and which are large enough
to possibly be a timestamp
parent 7c4f5319
No related branches found
No related tags found
No related merge requests found
......@@ -24,15 +24,19 @@ class ClientLogParser(Parser):
at_start = True
timestamp = None
for line in f:
line = line.strip()
line = line.rstrip()
if not line:
continue
split_line = line.split(None, 1)
if split_line[0].isdigit() and len(split_line) > 1:
timestamp = float(int(split_line[0])) * 1e-6
# remove timestamp at line start
line = split_line[1]
# ignore number prefixed with whitespace
if line[0].isdigit() and split_line[0].isdigit() and len(split_line) > 1:
ts = float(int(split_line[0])) * 1e-6
# ignore numbers that are too low to be timestamps
if ts > 1000:
timestamp = ts
# remove timestamp at line start
line = split_line[1]
# keep last timestamp when encountering a line without
if at_start:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment