Sha256: 0314ab8715bee42e20c5438aef07f70747e21047a660d96cc7821bf83b109f16

Contents?: true

Size: 1.01 KB

Versions: 17

Compression:

Stored size: 1.01 KB

Contents

module Timber
  module Integrations
    module ActiveRecord
      class LogSubscriber < Integrator
        # The log subscriber that replaces the default `ActiveRecord::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 < ::ActiveRecord::LogSubscriber
          def sql(event)
            r = super(event)

            if @message
              payload = event.payload
              event = Events::SQLQuery.new(
                sql: payload[:sql],
                time_ms: event.duration,
                message: @message
              )

              logger.debug event

              @message = nil
            end

            r
          end

          private
            def debug(message)
              @message = message
            end
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
timber-2.0.17 lib/timber/integrations/active_record/log_subscriber/timber_log_subscriber.rb
timber-2.0.16 lib/timber/integrations/active_record/log_subscriber/timber_log_subscriber.rb
timber-2.0.15 lib/timber/integrations/active_record/log_subscriber/timber_log_subscriber.rb
timber-2.0.14 lib/timber/integrations/active_record/log_subscriber/timber_log_subscriber.rb
timber-2.0.12 lib/timber/integrations/active_record/log_subscriber/timber_log_subscriber.rb
timber-2.0.11 lib/timber/integrations/active_record/log_subscriber/timber_log_subscriber.rb
timber-2.0.10 lib/timber/integrations/active_record/log_subscriber/timber_log_subscriber.rb
timber-2.0.9 lib/timber/integrations/active_record/log_subscriber/timber_log_subscriber.rb
timber-2.0.8 lib/timber/integrations/active_record/log_subscriber/timber_log_subscriber.rb
timber-2.0.7 lib/timber/integrations/active_record/log_subscriber/timber_log_subscriber.rb
timber-2.0.6 lib/timber/integrations/active_record/log_subscriber/timber_log_subscriber.rb
timber-2.0.5 lib/timber/integrations/active_record/log_subscriber/timber_log_subscriber.rb
timber-2.0.4 lib/timber/integrations/active_record/log_subscriber/timber_log_subscriber.rb
timber-2.0.3 lib/timber/integrations/active_record/log_subscriber/timber_log_subscriber.rb
timber-2.0.2 lib/timber/integrations/active_record/log_subscriber/timber_log_subscriber.rb
timber-2.0.1 lib/timber/integrations/active_record/log_subscriber/timber_log_subscriber.rb
timber-2.0.0 lib/timber/integrations/active_record/log_subscriber/timber_log_subscriber.rb