class Sapience::Extensions::ActiveRecord::LogSubscriber
Public Instance Methods
identity(event)
click to toggle source
# File lib/sapience/extensions/active_record/log_subscriber.rb, line 11 def identity(event) event = normalize(event) debug(event) if logger && event end
Also aliased as: sql
Private Instance Methods
extract_sql(data)
click to toggle source
# File lib/sapience/extensions/active_record/log_subscriber.rb, line 38 def extract_sql(data) { sql: data[:sql].squeeze(" ") } end
normalize(event)
click to toggle source
# File lib/sapience/extensions/active_record/log_subscriber.rb, line 19 def normalize(event) data = event.payload return if data[:name] == "SCHEMA" data.merge! runtimes(event) data.merge! extract_sql(data) data.merge! tags(data) end
runtimes(event)
click to toggle source
# File lib/sapience/extensions/active_record/log_subscriber.rb, line 30 def runtimes(event) if event.duration { duration: event.duration.to_f.round(2) } else {} end end