Sha256: a6df427208ec95883113b00e47404843c191869040a7d668e41d39b016ff19c3
Contents?: true
Size: 1.11 KB
Versions: 24
Compression:
Stored size: 1.11 KB
Contents
module Switchman module ActiveRecord module LogSubscriber def self.included(klass) klass.send(:remove_method, :sql) end # sadly, have to completely replace this def sql(event) self.class.runtime += event.duration return unless logger.debug? payload = event.payload return if 'SCHEMA' == payload[:name] name = '%s (%.1fms)' % [payload[:name], event.duration] sql = payload[:sql].squeeze(' ') binds = nil shard = payload[:shard] shard = " [#{shard[:database_server_id]}:#{shard[:id]} #{shard[:env]}]" if shard unless (payload[:binds] || []).empty? binds = " " + payload[:binds].map { |col,v| if col [col.name, v] else [nil, v] end }.inspect end if odd? name = color(name, self.class::CYAN, true) sql = color(sql, nil, true) else name = color(name, self.class::MAGENTA, true) end debug " #{name} #{sql}#{binds}#{shard}" end end end end
Version data entries
24 entries across 24 versions & 1 rubygems