Sha256: 598ac113c6418c7d0b24aec41fd20ceea0c7a31b12ccb7592ffb166ea4c0a18a

Contents?: true

Size: 1.31 KB

Versions: 23

Compression:

Stored size: 1.31 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)
            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
        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_controller/log_subscriber/timber_log_subscriber.rb
timber-2.0.23 lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb
timber-2.0.22 lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb
timber-2.0.21 lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb
timber-2.0.20 lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb
timber-2.0.19 lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb
timber-2.0.17 lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb
timber-2.0.16 lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb
timber-2.0.15 lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb
timber-2.0.14 lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb
timber-2.0.12 lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb
timber-2.0.11 lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb
timber-2.0.10 lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb
timber-2.0.9 lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb
timber-2.0.8 lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb
timber-2.0.7 lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb
timber-2.0.6 lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb
timber-2.0.5 lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb
timber-2.0.4 lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb
timber-2.0.3 lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb