Parent

Class/Module Index [+]

Quicksearch

Rails::Rack::LogTailer

Constants

EnvironmentLog

Public Class Methods

new(app, log = nil) click to toggle source
# File lib/rails/rack/log_tailer.rb, line 6
def initialize(app, log = nil)
  @app = app

  path = Pathname.new(log || EnvironmentLog).cleanpath
  @cursor = ::File.size(path)
  @last_checked = Time.now.to_f

  @file = ::File.open(path, 'r')
end

Public Instance Methods

call(env) click to toggle source
# File lib/rails/rack/log_tailer.rb, line 16
def call(env)
  response = @app.call(env)
  tail_log
  response
end
tail_log() click to toggle source
# File lib/rails/rack/log_tailer.rb, line 22
def tail_log
  @file.seek @cursor

  mod = @file.mtime.to_f
  if mod > @last_checked
    contents = @file.read
    @last_checked = mod
    @cursor += contents.size
    $stdout.print contents
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.