diff options
author | John Newbery <john@johnnewbery.com> | 2018-08-27 14:16:33 -0400 |
---|---|---|
committer | John Newbery <john@johnnewbery.com> | 2018-08-27 14:31:44 -0400 |
commit | 16e288acdd61fa5fa5e39f3936fb50499f82c085 (patch) | |
tree | 3cc5f4488f93f8514dfab63265373044622fbc2f /test | |
parent | 995dd89d884bda3fb5ca1885c5887d989cd2cad3 (diff) |
test padding non micro timestamps
Diffstat (limited to 'test')
-rwxr-xr-x | test/functional/combine_logs.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/test/functional/combine_logs.py b/test/functional/combine_logs.py index f5eb4c4537..3759913e44 100755 --- a/test/functional/combine_logs.py +++ b/test/functional/combine_logs.py @@ -13,7 +13,7 @@ import re import sys # Matches on the date format at the start of the log event -TIMESTAMP_PATTERN = re.compile(r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{6}Z") +TIMESTAMP_PATTERN = re.compile(r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{6})?Z") LogEvent = namedtuple('LogEvent', ['timestamp', 'source', 'event']) @@ -75,8 +75,13 @@ def get_log_events(source, logfile): if time_match: if event: yield LogEvent(timestamp=timestamp, source=source, event=event.rstrip()) - event = line timestamp = time_match.group() + if time_match.group(1) is None: + # timestamp does not have microseconds. Add zeroes. + timestamp_micro = timestamp.replace("Z", ".000000Z") + line = line.replace(timestamp, timestamp_micro) + timestamp = timestamp_micro + event = line # if it doesn't have a timestamp, it's a continuation line of the previous log. else: # Add the line. Prefix with space equivalent to the source + timestamp so log lines are aligned |