Sha256: 19ff20021387215a637c0cf93b8dc423f80a09d313b9f441efb54f376afdcbcf
Contents?: true
Size: 1.08 KB
Versions: 37
Compression:
Stored size: 1.08 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 #{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
37 entries across 37 versions & 1 rubygems