mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 01:32:36 +02:00
dont allow broken/corrupt log to stop log parsing
This commit is contained in:
parent
d6b33ddad8
commit
b9fa24e479
1 changed files with 42 additions and 35 deletions
|
@ -22,6 +22,7 @@ class Stat < Sequel::Model
|
|||
|
||||
logfile = File.open log_path, 'r'
|
||||
|
||||
begin
|
||||
while hit = logfile.gets
|
||||
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] += 1
|
||||
end
|
||||
rescue => e
|
||||
puts "Log parse exception: #{e.inspect}"
|
||||
logfile.close
|
||||
FileUtils.mv log_path, log_path.gsub('.log', '.brokenlog')
|
||||
next
|
||||
end
|
||||
|
||||
logfile.close
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue