Don't crash if we can't parse lines.. This shouldn't happen often, but may or may not happen, no reason to get the pants in a twist..

This commit is contained in:
2024-05-07 21:17:08 +02:00
parent a69c0c9cf4
commit e6ecf5e76d

View File

@ -144,7 +144,11 @@ def parse_line(input_line: str) -> dict:
now = datetime.now()
except IndexError:
return None
logline_time = datetime.strptime(str(now.year) + ' ' + month + ' ' + str(dateint) + ' ' + str(timestr), '%Y %b %d %H:%M:%S')
try:
logline_time = datetime.strptime(str(now.year) + ' ' + month + ' ' + str(dateint) + ' ' + str(timestr), '%Y %b %d %H:%M:%S')
except ValueError:
logging.error('Could not parse line ' + str(input_line))
return None
#If this is in the future, this probably means the data is from last year
if logline_time > now:
#We're in the future. Prettu sure the future is not yet, we're in last year