diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-01-20 10:23:46 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-01-20 10:23:46 -0800 |
commit | de41f5a9799cbce276ca9c439c99f4377191b36d (patch) | |
tree | 0ddcc23727e9ffd0d35aa95c19d5d85f7d7fe553 /railties | |
parent | 8c2dc4cd043ee2b5b756a737801a62fb7bfc7ba2 (diff) | |
parent | cf1f563473369c02917608e9b4c461328b6f8dac (diff) | |
download | rails-de41f5a9799cbce276ca9c439c99f4377191b36d.tar.gz rails-de41f5a9799cbce276ca9c439c99f4377191b36d.tar.bz2 rails-de41f5a9799cbce276ca9c439c99f4377191b36d.zip |
Merge pull request #4528 from j-manu/log-tailer-fix
Fix for log tailer when the log file doesn't exist.
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/rack/log_tailer.rb | 10 |
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? |