aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails
diff options
context:
space:
mode:
authorManu J <manu.1982@gmail.com>2012-01-19 01:42:37 +0530
committerManu J <manu.1982@gmail.com>2012-01-20 00:33:07 +0530
commitcf1f563473369c02917608e9b4c461328b6f8dac (patch)
tree17e1abd8665dd8d51055a94b4af4d61fd2987cc0 /railties/lib/rails
parent423b2626d85f75bb5fec03909ff8963bded7c7d5 (diff)
downloadrails-cf1f563473369c02917608e9b4c461328b6f8dac.tar.gz
rails-cf1f563473369c02917608e9b4c461328b6f8dac.tar.bz2
rails-cf1f563473369c02917608e9b4c461328b6f8dac.zip
Fix for log tailer when the log file doesn't exist.
Diffstat (limited to 'railties/lib/rails')
-rw-r--r--railties/lib/rails/rack/log_tailer.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/railties/lib/rails/rack/log_tailer.rb b/railties/lib/rails/rack/log_tailer.rb
index 830d840894..18f22e8089 100644
--- a/railties/lib/rails/rack/log_tailer.rb
+++ b/railties/lib/rails/rack/log_tailer.rb
@@ -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?