Sha256: 285b86f7de440215e1553b56652adf4140620e5b6aa112a641967cc1995f5ad3

Contents?: true

Size: 1.43 KB

Versions: 34

Compression:

Stored size: 1.43 KB

Contents

module Timber
  module Integrations
    module ActionController
      class LogSubscriber < Integrator
        # The log subscriber that replaces the default `ActionController::LogSubscriber`.
        # The intent of this subscriber is to, as transparently as possible, properly
        # track events that are being logged here. This LogSubscriber will never change
        # default behavior / log messages.
        #
        # @private
        class TimberLogSubscriber < ::ActionController::LogSubscriber
          def start_processing(event)
            return true if silence?

            info do
              payload = event.payload
              params  = payload[:params].except(*INTERNAL_PARAMS)
              format  = extract_format(payload)
              format  = format.to_s.upcase if format.is_a?(Symbol)

              Events::ControllerCall.new(
                controller: payload[:controller],
                action: payload[:action],
                format: format,
                params: params
              )
            end
          end

          private
            def extract_format(payload)
              if payload.key?(:format)
                payload[:format] # rails > 4.X
              elsif payload.key?(:formats)
                payload[:formats].first # rails 3.X
              end
            end

            def silence?
              ActionController.silence?
            end
        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_controller/log_subscriber/timber_log_subscriber.rb
timber-2.6.1 lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb
timber-2.6.0 lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb
timber-2.6.0.pre.beta2 lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb
timber-2.6.0.pre.beta1 lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb
timber-2.5.1 lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb
timber-2.5.0 lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb
timber-2.4.0 lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb
timber-2.3.4 lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb
timber-2.3.3 lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb
timber-2.3.2 lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb
timber-2.3.1 lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb
timber-2.3.0 lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb
timber-2.2.3 lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb
timber-2.2.2 lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb
timber-2.2.1 lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb
timber-2.2.0 lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb
timber-2.1.10 lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb
timber-2.1.9 lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb
timber-2.1.8 lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb