Changeset View
Changeset View
Standalone View
Standalone View
test/functional/combine_logs.py
Show First 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | |||||
def get_log_events(source, logfile): | def get_log_events(source, logfile): | ||||
"""Generator function that returns individual log events. | """Generator function that returns individual log events. | ||||
Log events may be split over multiple lines. We use the timestamp | Log events may be split over multiple lines. We use the timestamp | ||||
regex match as the marker for a new log event.""" | regex match as the marker for a new log event.""" | ||||
try: | try: | ||||
with open(logfile, 'r') as infile: | with open(logfile, 'r', encoding='utf-8') as infile: | ||||
event = '' | event = '' | ||||
timestamp = '' | timestamp = '' | ||||
for line in infile: | for line in infile: | ||||
# skip blank lines | # skip blank lines | ||||
if line == '\n': | if line == '\n': | ||||
continue | continue | ||||
# if this line has a timestamp, it's the start of a new log event. | # if this line has a timestamp, it's the start of a new log event. | ||||
time_match = TIMESTAMP_PATTERN.match(line) | time_match = TIMESTAMP_PATTERN.match(line) | ||||
▲ Show 20 Lines • Show All 43 Lines • Show Last 20 Lines |