Froze rails gems
[depot.git] / vendor / rails / railties / lib / rails / rack / logger.rb
1 module Rails
2 module Rack
3 class Logger
4 EnvironmentLog = "#{File.expand_path(Rails.root)}/log/#{Rails.env}.log"
5
6 def initialize(app, log = nil)
7 @app = app
8 @path = Pathname.new(log || EnvironmentLog).cleanpath
9 @cursor = ::File.size(@path)
10 @last_checked = Time.now
11 end
12
13 def call(env)
14 response = @app.call(env)
15 ::File.open(@path, 'r') do |f|
16 f.seek @cursor
17 if f.mtime > @last_checked
18 contents = f.read
19 @last_checked = f.mtime
20 @cursor += contents.length
21 print contents
22 end
23 end
24 response
25 end
26 end
27 end
28 end