File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change 13
13
import sys
14
14
15
15
# 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" )
17
17
18
18
LogEvent = namedtuple ('LogEvent' , ['timestamp' , 'source' , 'event' ])
19
19
@@ -75,8 +75,13 @@ def get_log_events(source, logfile):
75
75
if time_match :
76
76
if event :
77
77
yield LogEvent (timestamp = timestamp , source = source , event = event .rstrip ())
78
- event = line
79
78
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
80
85
# if it doesn't have a timestamp, it's a continuation line of the previous log.
81
86
else :
82
87
# Add the line. Prefix with space equivalent to the source + timestamp so log lines are aligned
You can’t perform that action at this time.
0 commit comments