Sha256: 16cd1535eced0a41df7233dc29cedda5a856d12a859d81b0adb1abcb6a7a6be7

Contents?: true

Size: 1.54 KB

Versions: 34

Compression:

Stored size: 1.54 KB

Contents

require "timber/integrator"

module Timber
  module Integrations
    module ActionDispatch
      # Reponsible for disabled logging in the ActionDispatch::DebugExceptions
      # Rack middleware. We cannot simply remove the middleware because it is
      # coupled with displaying an exception debug screen if debug exceptions is enabled.
      #
      # @private
      class DebugExceptions < Integrator

        # Patch for disabling logging
        #
        # @private
        module InstanceMethods
          def self.included(klass)
            klass.class_eval do
              private
                def logger(*args)
                  nil
                end
            end
          end
        end

        def initialize
          begin
            # Rails >= 3.1
            require "action_dispatch/middleware/debug_exceptions"
          rescue LoadError
            # Rails < 3.1
            require "action_dispatch/middleware/show_exceptions"
          end
        rescue LoadError => e
          raise RequirementNotMetError.new(e.message)
        end

        def integrate!
          if defined?(::ActionDispatch::DebugExceptions) && !::ActionDispatch::DebugExceptions.include?(InstanceMethods)
            ::ActionDispatch::DebugExceptions.send(:include, InstanceMethods)
          end

          if defined?(::ActionDispatch::ShowExceptions) && !::ActionDispatch::ShowExceptions.include?(InstanceMethods)
            ::ActionDispatch::ShowExceptions.send(:include, InstanceMethods)
          end

          true
        end
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
timber-2.6.2 lib/timber/integrations/action_dispatch/debug_exceptions.rb
timber-2.6.1 lib/timber/integrations/action_dispatch/debug_exceptions.rb
timber-2.6.0 lib/timber/integrations/action_dispatch/debug_exceptions.rb
timber-2.6.0.pre.beta2 lib/timber/integrations/action_dispatch/debug_exceptions.rb
timber-2.6.0.pre.beta1 lib/timber/integrations/action_dispatch/debug_exceptions.rb
timber-2.5.1 lib/timber/integrations/action_dispatch/debug_exceptions.rb
timber-2.5.0 lib/timber/integrations/action_dispatch/debug_exceptions.rb
timber-2.4.0 lib/timber/integrations/action_dispatch/debug_exceptions.rb
timber-2.3.4 lib/timber/integrations/action_dispatch/debug_exceptions.rb
timber-2.3.3 lib/timber/integrations/action_dispatch/debug_exceptions.rb
timber-2.3.2 lib/timber/integrations/action_dispatch/debug_exceptions.rb
timber-2.3.1 lib/timber/integrations/action_dispatch/debug_exceptions.rb
timber-2.3.0 lib/timber/integrations/action_dispatch/debug_exceptions.rb
timber-2.2.3 lib/timber/integrations/action_dispatch/debug_exceptions.rb
timber-2.2.2 lib/timber/integrations/action_dispatch/debug_exceptions.rb
timber-2.2.1 lib/timber/integrations/action_dispatch/debug_exceptions.rb
timber-2.2.0 lib/timber/integrations/action_dispatch/debug_exceptions.rb
timber-2.1.10 lib/timber/integrations/action_dispatch/debug_exceptions.rb
timber-2.1.9 lib/timber/integrations/action_dispatch/debug_exceptions.rb
timber-2.1.8 lib/timber/integrations/action_dispatch/debug_exceptions.rb