def log_formatter(line):
split = line.split(' / ')
if len(split) == 4:
return {
# Other parsing options: http://stackoverflow.com/questions/466345/converting-string-into-datetime
#
"timestamp": date_parse(split[0] + "+00"),
"level": logging.getLevelName(split[1]),
"message": split[3],
"process": split[2],
"device_id": None,
}
elif len(split) == 6:
return {
# Other parsing options: http://stackoverflow.com/questions/466345/converting-string-into-datetime
"timestamp": date_parse(split[0]),
"level": logging.getLevelName(split[1]),
"message": split[5],
"process": split[3],
"device_id": split[4],
}
else:
raise RuntimeError("The logs in the log file are of an unknown format, cannot continue. "
"Line: {}".format(line))
评论列表
文章目录