Skip to content

Commit 16e288a

Browse files
committed
test padding non micro timestamps
1 parent 995dd89 commit 16e288a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

test/functional/combine_logs.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import sys
1414

1515
# Matches on the date format at the start of the log event
16-
TIMESTAMP_PATTERN = re.compile(r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{6}Z")
16+
TIMESTAMP_PATTERN = re.compile(r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{6})?Z")
1717

1818
LogEvent = namedtuple('LogEvent', ['timestamp', 'source', 'event'])
1919

@@ -75,8 +75,13 @@ def get_log_events(source, logfile):
7575
if time_match:
7676
if event:
7777
yield LogEvent(timestamp=timestamp, source=source, event=event.rstrip())
78-
event = line
7978
timestamp = time_match.group()
79+
if time_match.group(1) is None:
80+
# timestamp does not have microseconds. Add zeroes.
81+
timestamp_micro = timestamp.replace("Z", ".000000Z")
82+
line = line.replace(timestamp, timestamp_micro)
83+
timestamp = timestamp_micro
84+
event = line
8085
# if it doesn't have a timestamp, it's a continuation line of the previous log.
8186
else:
8287
# Add the line. Prefix with space equivalent to the source + timestamp so log lines are aligned

0 commit comments

Comments
 (0)