Module: Timber::Integrations::Rails::RackLogger::InstanceMethods

Defined in:
lib/timber-rails/rack_logger.rb

Constant Summary collapse

LOGGER =
::Logger.new(nil)

Class Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/timber-rails/rack_logger.rb', line 17

def self.included(klass)
  klass.class_eval do
    private
      if ::Rails::VERSION::MAJOR == 3
        # Rails 3.2 calls Rails.logger directly in call_app, so we
        # will just replace it with a version that doesn't
        def call_app(_, env)
          # Put some space between requests in development logs.
          if ::Rails.env.development?
            ::Rails.logger.info ''
            ::Rails.logger.info ''
          end
          @app.call(env)
        ensure
          ActiveSupport::LogSubscriber.flush_all!
        end
      end

      # Rails > 3.2 uses a logger method. Muting logs is accomplished by
      # passing a dummy logger instance with a nil log device.
      def logger
        LOGGER
      end
  end
end