Class: ActiveRecord::ModSqlLogSubscriber

Inherits:
LogSubscriber
  • Object
show all
Includes:
ActiveSupport::Configurable
Defined in:
lib/active_record/mod_sql_log_subscriber.rb

Constant Summary collapse

VERSION =
"0.2.0"

Instance Method Summary collapse

Instance Method Details

#sql(event) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/active_record/mod_sql_log_subscriber.rb', line 23

def sql(event)
  return if self.disable

  payload = event.payload
  sql = payload[:sql]

  return if sql.nil?
  return if payload[:cached]
  return if IGNORE_PAYLOAD_NAMES.include?(payload[:name])
  return unless target_sql_checker.match?(sql)

  send(self.log_level) do
    binds = type_casted_binds(payload[:type_casted_binds])
    formatter.call(sql, binds)
  end
end