Sha256: e23acda1c49742a683b310406950a160d2a1d45bde81e91935f290e2995f5074

Contents?: true

Size: 680 Bytes

Versions: 3

Compression:

Stored size: 680 Bytes

Contents

module Rails
  module Rack
    class Logger
      EnvironmentLog = "#{File.expand_path(Rails.root)}/log/#{Rails.env}.log"

      def initialize(app, log = nil)
        @app = app
        @path = Pathname.new(log || EnvironmentLog).cleanpath
        @cursor = ::File.size(@path)
        @last_checked = Time.now
      end

      def call(env)
        response = @app.call(env)
        ::File.open(@path, 'r') do |f|
          f.seek @cursor
          if f.mtime > @last_checked
            contents = f.read
            @last_checked = f.mtime
            @cursor += contents.length
            print contents
          end
        end
        response
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
usher-0.7.0 spec/rails2_2/vendor/rails/vendor/rails/railties/lib/rails/rack/logger.rb
rails-2.2.3 lib/rails/rack/logger.rb
rails-2.2.2 lib/rails/rack/logger.rb