Sha256: a70496f51fc54c8331119a605b4c3ca4a555e82578e3da06e10d66ede0db18e7

Contents?: true

Size: 594 Bytes

Versions: 75

Compression:

Stored size: 594 Bytes

Contents

module Rails
  module Rack
    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)

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

      def call(env)
        response = @app.call(env)
        tail!
        response
      end

      def tail!
        @file.seek @cursor

        unless @file.eof?
          contents = @file.read
          @cursor = @file.tell
          $stdout.print contents
        end
      end
    end
  end
end

Version data entries

75 entries across 62 versions & 4 rubygems

Version Path
railties-3.1.12 lib/rails/rack/log_tailer.rb
railties-3.1.11 lib/rails/rack/log_tailer.rb
railties-3.1.10 lib/rails/rack/log_tailer.rb
railties-3.1.9 lib/rails/rack/log_tailer.rb
railties-3.1.8 lib/rails/rack/log_tailer.rb
railties-3.1.7 lib/rails/rack/log_tailer.rb
challah-0.6.2 vendor/bundle/gems/railties-3.2.3/lib/rails/rack/log_tailer.rb
challah-0.6.2 vendor/bundle/gems/railties-3.2.2/lib/rails/rack/log_tailer.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/rack/log_tailer.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/vendor/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/rack/log_tailer.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/rack/log_tailer.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/vendor/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/rack/log_tailer.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/vendor/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/rack/log_tailer.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/rack/log_tailer.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/vendor/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/rack/log_tailer.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/rack/log_tailer.rb
rails-uploader-0.0.4 vendor/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/rack/log_tailer.rb
railties-3.1.6 lib/rails/rack/log_tailer.rb
challah-0.6.1 vendor/bundle/gems/railties-3.2.3/lib/rails/rack/log_tailer.rb
challah-0.6.1 vendor/bundle/gems/railties-3.2.1/lib/rails/rack/log_tailer.rb