Sha256: 92aba98bd7ca9a03908251b60dbb19a7d5f1fa9bf1a25b1581f2d709286e1b01

Contents?: true

Size: 1.51 KB

Versions: 23

Compression:

Stored size: 1.51 KB

Contents

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

23 entries across 23 versions & 1 rubygems

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