dont allow broken/corrupt log to stop log parsing

This commit is contained in:
Kyle Drake 2016-10-06 10:27:55 -05:00
parent d6b33ddad8
commit b9fa24e479

View file

@ -22,6 +22,7 @@ class Stat < Sequel::Model
logfile = File.open log_path, 'r' logfile = File.open log_path, 'r'
begin
while hit = logfile.gets while hit = logfile.gets
hit_array = hit.strip.split "\t" hit_array = hit.strip.split "\t"
@ -73,6 +74,12 @@ class Stat < Sequel::Model
site_logs[log_time][username][:paths][path] ||= 0 site_logs[log_time][username][:paths][path] ||= 0
site_logs[log_time][username][:paths][path] += 1 site_logs[log_time][username][:paths][path] += 1
end end
rescue => e
puts "Log parse exception: #{e.inspect}"
logfile.close
FileUtils.mv log_path, log_path.gsub('.log', '.brokenlog')
next
end
logfile.close logfile.close