Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

Fix for log tailer when the log file doesn't exist.
  • Loading branch information...
commit 05bee990b4bd0ce3b02e75399c857e168f41edb6 1 parent 006de25
@tenderlove tenderlove authored
Showing with 7 additions and 3 deletions.
  1. +7 −3 railties/lib/rails/rack/log_tailer.rb
View
10 railties/lib/rails/rack/log_tailer.rb
@@ -4,10 +4,13 @@ class LogTailer
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 @@ def call(env)
end
def tail!
+ return unless @cursor
@file.seek @cursor
unless @file.eof?
Please sign in to comment.
Something went wrong with that request. Please try again.