Browse files

Refactor log-tailer to depend on File#eof? rather than File#mtime

[#5220 state:resolved]

Eliminate 1 instance variable and 1 local variable.

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
1 parent 1466f31 commit e1142dfcae036bd8c6400962f9e07112b750b730 Curtis Cablegram committed with josevalim Jul 29, 2010
Showing with 1 addition and 4 deletions.
  1. +1 −4 railties/lib/rails/rack/log_tailer.rb
View
5 railties/lib/rails/rack/log_tailer.rb
@@ -6,7 +6,6 @@ def initialize(app, log = nil)
path = Pathname.new(log || "#{File.expand_path(Rails.root)}/log/#{Rails.env}.log").cleanpath
@cursor = ::File.size(path)
- @last_checked = Time.now.to_f
@file = ::File.open(path, 'r')
end
@@ -20,10 +19,8 @@ def call(env)
def tail!
@file.seek @cursor
- mod = @file.mtime.to_f
- if mod > @last_checked
+ if !@file.eof?
contents = @file.read
- @last_checked = mod
@cursor = @file.tell
$stdout.print contents
end

0 comments on commit e1142df

Please sign in to comment.