Sha256: 85bb87210e50830b75d27d2b361c4dd8019a1a3bdfb4d023f04be54f082cd97f
Contents?: true
Size: 1.45 KB
Versions: 17
Compression:
Stored size: 1.45 KB
Contents
# We require all of ActiveRecord because the #logger method in ::ActiveRecord::LogSubscriber # uses ActiveRecord::Base. We can't require active_record/base directly because ActiveRecord # does not require files properly and we receive unintialized constant errors. require "active_record" require "active_record/log_subscriber" module Logtail 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 LogtailLogSubscriber < ::ActiveRecord::LogSubscriber def sql(event) return true if silence? r = super(event) if @message payload = event.payload sql_event = Events::SQLQuery.new( sql: payload[:sql], duration_ms: event.duration, message: @message, ) logger.debug sql_event @message = nil end r end private def debug(message) @message = message end def silence? ActiveRecord.silence? end end end end end end
Version data entries
17 entries across 17 versions & 1 rubygems