Sha256: cd195d3a9c0809d9a0126c39def5b5e0d2f3a3474a5ef4cc137363eeab67c9e2

Contents?: true

Size: 878 Bytes

Versions: 11

Compression:

Stored size: 878 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)

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

            logger.debug event
          end
        end

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
timber-1.1.14 lib/timber/probes/active_record_log_subscriber/log_subscriber.rb
timber-1.1.13 lib/timber/probes/active_record_log_subscriber/log_subscriber.rb
timber-1.1.12 lib/timber/probes/active_record_log_subscriber/log_subscriber.rb
timber-1.1.11 lib/timber/probes/active_record_log_subscriber/log_subscriber.rb
timber-1.1.10 lib/timber/probes/active_record_log_subscriber/log_subscriber.rb
timber-1.1.9 lib/timber/probes/active_record_log_subscriber/log_subscriber.rb
timber-1.1.8 lib/timber/probes/active_record_log_subscriber/log_subscriber.rb
timber-1.1.7 lib/timber/probes/active_record_log_subscriber/log_subscriber.rb
timber-1.1.6 lib/timber/probes/active_record_log_subscriber/log_subscriber.rb
timber-1.1.5 lib/timber/probes/active_record_log_subscriber/log_subscriber.rb
timber-1.1.4 lib/timber/probes/active_record_log_subscriber/log_subscriber.rb