Sha256: c5f105a379724e90fd91436ed33deb6450687ebf02efea64a926873f6fc17d5c

Contents?: true

Size: 1.51 KB

Versions: 23

Compression:

Stored size: 1.51 KB

Contents

module Timber
  module Integrations
    module Rails
      # Disables the default rail's rack logging. Note, we cannot simply uninstall this rack
      # middleware because rails couples this with ActiveSupport instrumentation. As such,
      # we simply disable the logger and let our Rack middleware handle the logging.
      #
      # See: https://github.com/rails/rails/blob/80e66cc4d90bf8c15d1a5f6e3152e90147f00772/railties/lib/rails/rack/logger.rb#L34
      #
      # @private
      class RackLogger < Integrator

        # @private
        module InstanceMethods
          LOGGER = ::Logger.new(nil)

          def self.included(klass)
            klass.class_eval do
              private
                # Rails 3.2 calls Rails.logger directly, so this is the first place
                # we can mute the logger calls.
                def started_request_message(*args)
                  ""
                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
        end

        def initialize
          require "rails/rack/logger"
        rescue LoadError => e
          raise RequirementNotMetError.new(e.message)
        end

        def integrate!
          return true if ::Rails::Rack::Logger.include?(InstanceMethods)

          ::Rails::Rack::Logger.send(:include, InstanceMethods)
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
timber-2.0.24 lib/timber/integrations/rails/rack_logger.rb
timber-2.0.23 lib/timber/integrations/rails/rack_logger.rb
timber-2.0.22 lib/timber/integrations/rails/rack_logger.rb
timber-2.0.21 lib/timber/integrations/rails/rack_logger.rb
timber-2.0.20 lib/timber/integrations/rails/rack_logger.rb
timber-2.0.19 lib/timber/integrations/rails/rack_logger.rb
timber-2.0.17 lib/timber/integrations/rails/rack_logger.rb
timber-2.0.16 lib/timber/integrations/rails/rack_logger.rb
timber-2.0.15 lib/timber/integrations/rails/rack_logger.rb
timber-2.0.14 lib/timber/integrations/rails/rack_logger.rb
timber-2.0.12 lib/timber/integrations/rails/rack_logger.rb
timber-2.0.11 lib/timber/integrations/rails/rack_logger.rb
timber-2.0.10 lib/timber/integrations/rails/rack_logger.rb
timber-2.0.9 lib/timber/integrations/rails/rack_logger.rb
timber-2.0.8 lib/timber/integrations/rails/rack_logger.rb
timber-2.0.7 lib/timber/integrations/rails/rack_logger.rb
timber-2.0.6 lib/timber/integrations/rails/rack_logger.rb
timber-2.0.5 lib/timber/integrations/rails/rack_logger.rb
timber-2.0.4 lib/timber/integrations/rails/rack_logger.rb
timber-2.0.3 lib/timber/integrations/rails/rack_logger.rb