Sha256: 607f6b49e7c8db919a58f580a6dd73cef38f0d6cb90e5539315d56c7dd30696a
Contents?: true
Size: 1.11 KB
Versions: 13
Compression:
Stored size: 1.11 KB
Contents
# frozen_string_literal: true module Switchman module ActiveRecord module LogSubscriber # sadly, have to completely replace this def sql(event) self.class.runtime += event.duration return unless logger.debug? payload = event.payload return if ::ActiveRecord::LogSubscriber::IGNORE_PAYLOAD_NAMES.include?(payload[:name]) name = "#{payload[:name]} (#{event.duration.round(1)}ms)" name = "CACHE #{name}" if payload[:cached] sql = payload[:sql].squeeze(" ") binds = nil shard = payload[:shard] shard = " [#{shard[:database_server_id]}:#{shard[:id]} #{shard[:env]}]" if shard unless (payload[:binds] || []).empty? casted_params = type_casted_binds(payload[:type_casted_binds]) binds = " " + payload[:binds].zip(casted_params).map do |attr, value| render_bind(attr, value) end.inspect end name = colorize_payload_name(name, payload[:name]) sql = color(sql, sql_color(sql), true) debug " #{name} #{sql}#{binds}#{shard}" end end end end
Version data entries
13 entries across 13 versions & 1 rubygems