Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix for log tailer when the log file doesn't exist.

  • Loading branch information...
commit cf1f563473369c02917608e9b4c461328b6f8dac 1 parent 423b262
@j-manu j-manu 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

Noticing that the log path is defined both here and in Rails::Application::Configuration#paths. Any reason?

@drogus Collaborator
drogus added a note

Nope, no reason. It should use paths from app config to allow to change it easily (this is hardcoded which is bad). Good catch, please submit a pull request if you would like to fix it. If no, please ping me or open an issue, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
- @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?
@aceofspades

Noticing that the log path is defined both here and in Rails::Application::Configuration#paths. Any reason?

@drogus

Nope, no reason. It should use paths from app config to allow to change it easily (this is hardcoded which is bad). Good catch, please submit a pull request if you would like to fix it. If no, please ping me or open an issue, thanks!

Please sign in to comment.
Something went wrong with that request. Please try again.