Commit dbb48568 authored by thomas.forbriger's avatar thomas.forbriger Committed by Checksum Backup @bromo

csbackntfy: gracefully skip ill-formatted log lines

parent 3a7aadbe
......@@ -276,24 +276,24 @@ def main(argv=None):
timeStamp=dt.datetime.strptime(str(now.year)+" "+" ".join(str(n)
for n in line.split()[0:3]),"%Y %b %d %H:%M:%S")
except:
logger.getLogger().error("Error while parsing log line: '%s'" % line)
raise Error("Error while parsing log line from file %s" % path,
eCodes.GLOBAL_UnhandledException)
if 'CRITICAL' in line:
if timeStamp > timeLimit:
criticalList.append("logfile: "+path+"\n"+line)
elif 'ERROR' in line:
if timeStamp > timeLimit:
errorList.append("logfile: "+path+"\n"+line)
elif 'WARNING' in line:
if timeStamp > timeLimit:
warningDeque.appendleft("logfile: "+path+"\n"+line)
elif 'INFO' in line:
infoDeque.appendleft("logfile: "+path+"\n"+line)
logger.getLogger().error("Error while parsing log line: '%s'"
% line)
else:
logger.getLogger().info("Illegal line in logfile found")
logger.getLogger().info(" Line does not contain any of the csback message level keywords")
logger.getLogger().info(" The log line is: '%s'" % line)
if 'CRITICAL' in line:
if timeStamp > timeLimit:
criticalList.append("logfile: "+path+"\n"+line)
elif 'ERROR' in line:
if timeStamp > timeLimit:
errorList.append("logfile: "+path+"\n"+line)
elif 'WARNING' in line:
if timeStamp > timeLimit:
warningDeque.appendleft("logfile: "+path+"\n"+line)
elif 'INFO' in line:
infoDeque.appendleft("logfile: "+path+"\n"+line)
else:
logger.getLogger().info("Illegal line in logfile found")
logger.getLogger().info(" Line does not contain any of the csback message level keywords")
logger.getLogger().info(" The log line is: '%s'" % line)
except IOError as err:
raise Error("Error while reading logfiles: "+err.filename, \
eCodes.NTFY_IOError)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment