Sha256: 23a713f6e0beac03747a26cc168f04b5888e5dbd91b6c8878a68b36b6231cfdf
Contents?: true
Size: 1.21 KB
Versions: 2
Compression:
Stored size: 1.21 KB
Contents
ActiveRecord::LogSubscriber module ActiveRecord class LogSubscriber def sql(event) self.class.runtime += event.duration return unless logger.debug? payload = event.payload name = payload[:name] return if IGNORE_PAYLOAD_NAMES.include?(name) log_payload = { sql: payload[:sql], } log = { message: name, payload: log_payload, duration: event.duration } unless (payload[:binds] || []).empty? log_payload[:binds] = binds = {} if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR == 0 && Rails::VERSION::TINY <= 2 payload[:binds].each do |attr| attr_name, value = render_bind(attr) binds[attr_name] = value end elsif Rails::VERSION::MAJOR >= 5 casted_params = type_casted_binds(payload[:binds], payload[:type_casted_binds]) payload[:binds].zip(casted_params).map { |attr, value| render_bind(attr, value) } else payload[:binds].each do |col, v| attr_name, value = render_bind(col, v) binds[attr_name] = value end end end debug(log) end end end
Version data entries
2 entries across 2 versions & 1 rubygems