5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/loggun/modifiers/active_record/loggun_log_subscriber.rb', line 5
def sql(event)
payload = event.payload
return if IGNORE_PAYLOAD_NAMES.include?(payload[:name]) || payload[:cached]
available_keys = ::Loggun::Config.instance.modifiers.active_record.payload_keys&.map { |k| k.downcase.to_sym }
data = { sql: payload[:sql], name: payload[:name], duration: event.duration.round(4) }
source = respond_to?(:extract_query_source_location) ? (caller) : nil
data.merge!(source: source.gsub(/(?<=\.rb)(.*)$/, '')) if source
if available_keys&.any?
data.each { |k, _| data.delete(k) unless available_keys.include?(k) }
end
Loggun.info 'storage.sql.query', data
end
|