Sha256: 8e5825f88cd26052753a1874d91f1244fffe8e74e2aa501f171b472e057dc1f2

Contents?: true

Size: 828 Bytes

Versions: 18

Compression:

Stored size: 828 Bytes

Contents

module Timber
  module Probes
    class ActiveRecordLogSubscriber < Probe
      # 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.
      class LogSubscriber < ::ActiveRecord::LogSubscriber #:nodoc:
        def sql(event)
          super(event)

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

          logger.debug event
        end

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

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
timber-1.1.3 lib/timber/probes/active_record_log_subscriber/log_subscriber.rb
timber-1.1.2 lib/timber/probes/active_record_log_subscriber/log_subscriber.rb
timber-1.1.1 lib/timber/probes/active_record_log_subscriber/log_subscriber.rb
timber-1.1.0 lib/timber/probes/active_record_log_subscriber/log_subscriber.rb
timber-1.0.13 lib/timber/probes/active_record_log_subscriber/log_subscriber.rb
timber-1.0.12 lib/timber/probes/active_record_log_subscriber/log_subscriber.rb
timber-1.0.11 lib/timber/probes/active_record_log_subscriber/log_subscriber.rb
timber-1.0.10 lib/timber/probes/active_record_log_subscriber/log_subscriber.rb
timber-1.0.9 lib/timber/probes/active_record_log_subscriber/log_subscriber.rb
timber-1.0.8 lib/timber/probes/active_record_log_subscriber/log_subscriber.rb
timber-1.0.7 lib/timber/probes/active_record_log_subscriber/log_subscriber.rb
timber-1.0.6 lib/timber/probes/active_record_log_subscriber/log_subscriber.rb
timber-1.0.5 lib/timber/probes/active_record_log_subscriber/log_subscriber.rb
timber-1.0.4 lib/timber/probes/active_record_log_subscriber/log_subscriber.rb
timber-1.0.3 lib/timber/probes/active_record_log_subscriber/log_subscriber.rb
timberio-1.0.3 lib/timber/probes/active_record_log_subscriber/log_subscriber.rb
timberio-1.0.2 lib/timber/probes/active_record_log_subscriber/log_subscriber.rb
timberio-1.0.1 lib/timber/probes/active_record_log_subscriber/log_subscriber.rb