Sha256: ef3f08093c197d5aab37df6dcf9948399c67c570f85a2a2617050fd8e2ce22a4

Contents?: true

Size: 750 Bytes

Versions: 57

Compression:

Stored size: 750 Bytes

Contents

require 'active_support/core_ext/time/conversions'

module Rails
  module Rack
    # Log the request started and flush all loggers after it.
    class Logger < ActiveSupport::LogSubscriber
      def initialize(app)
        @app = app
      end

      def call(env)
        before_dispatch(env)
        @app.call(env)
      ensure
        after_dispatch(env)
      end

    protected

      def before_dispatch(env)
        request = ActionDispatch::Request.new(env)
        path = request.filtered_path

        info "\n\nStarted #{request.request_method} \"#{path}\" " \
             "for #{request.ip} at #{Time.now.to_default_s}"
      end

      def after_dispatch(env)
        ActiveSupport::LogSubscriber.flush_all!
      end
    end
  end
end

Version data entries

57 entries across 57 versions & 1 rubygems

Version Path
railties-3.1.12 lib/rails/rack/logger.rb
railties-3.1.11 lib/rails/rack/logger.rb
railties-3.0.20 lib/rails/rack/logger.rb
railties-3.1.10 lib/rails/rack/logger.rb
railties-3.0.19 lib/rails/rack/logger.rb
railties-3.1.9 lib/rails/rack/logger.rb
railties-3.0.18 lib/rails/rack/logger.rb
railties-3.1.8 lib/rails/rack/logger.rb
railties-3.0.17 lib/rails/rack/logger.rb
railties-3.1.7 lib/rails/rack/logger.rb
railties-3.0.16 lib/rails/rack/logger.rb
railties-3.0.15 lib/rails/rack/logger.rb
railties-3.1.6 lib/rails/rack/logger.rb
railties-3.0.14 lib/rails/rack/logger.rb
railties-3.1.5 lib/rails/rack/logger.rb
railties-3.0.13 lib/rails/rack/logger.rb
railties-3.1.5.rc1 lib/rails/rack/logger.rb
railties-3.0.13.rc1 lib/rails/rack/logger.rb
railties-3.1.4 lib/rails/rack/logger.rb
railties-3.0.12 lib/rails/rack/logger.rb