Class: ActiveRecord::LogSubscriber
- Inherits:
-
Object
- Object
- ActiveRecord::LogSubscriber
- Defined in:
- lib/sapience/extensions/active_record/log_subscriber.rb
Overview
rubocop:disable ClassAndModuleChildren
Instance Method Summary collapse
-
#sql(event) ⇒ Object
rubocop:disable AbcSize.
Instance Method Details
#sql(event) ⇒ Object
rubocop:disable AbcSize
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/sapience/extensions/active_record/log_subscriber.rb', line 4 def sql(event) # rubocop:disable AbcSize self.class.runtime += event.duration return unless logger.debug? payload = event.payload name = payload[:name] return if IGNORE_PAYLOAD_NAMES.include?(name) log = { message: name, sql: payload[:sql], duration: event.duration, } unless (payload[:binds] || []).empty? log[:binds] = binds = {} # Changed with Rails 5 if Rails.version.to_i >= 5 payload[:binds].each do |attr| attr_name, value = render_bind(attr) binds[attr_name] = value end else payload[:binds].each do |col, v| attr_name, value = render_bind(col, v) binds[attr_name] = value end end end debug(log) end |