1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #4528 from j-manu/log-tailer-fix

Fix for log tailer when the log file doesn't exist.
This commit is contained in:
Aaron Patterson 2012-01-20 10:23:46 -08:00
commit de41f5a979

View file

@ -4,10 +4,13 @@ module Rails
def initialize(app, log = nil)
@app = app
path = Pathname.new(log || "#{File.expand_path(Rails.root)}/log/#{Rails.env}.log").cleanpath
@cursor = ::File.size(path)
path = Pathname.new(log || "#{::File.expand_path(Rails.root)}/log/#{Rails.env}.log").cleanpath
@file = ::File.open(path, 'r')
@cursor = @file = nil
if ::File.exists?(path)
@cursor = ::File.size(path)
@file = ::File.open(path, 'r')
end
end
def call(env)
@ -17,6 +20,7 @@ module Rails
end
def tail!
return unless @cursor
@file.seek @cursor
unless @file.eof?