Sha256: 19bd4ea7e4ac2a593c97a99e8fb962b37be871ea302d4922683ee58be17e13dc
Contents?: true
Size: 693 Bytes
Versions: 14
Compression:
Stored size: 693 Bytes
Contents
# Implementation courtesy of db-charmer. module Octopus module LogSubscriber def self.included(base) base.send(:attr_accessor, :octopus_shard) base.alias_method_chain :sql, :octopus_shard base.alias_method_chain :debug, :octopus_shard end def sql_with_octopus_shard(event) self.octopus_shard = event.payload[:octopus_shard] sql_without_octopus_shard(event) end def debug_with_octopus_shard(msg) conn = octopus_shard ? color("[Shard: #{octopus_shard}]", ActiveSupport::LogSubscriber::GREEN, true) : '' debug_without_octopus_shard(conn + msg) end end end ActiveRecord::LogSubscriber.send(:include, Octopus::LogSubscriber)
Version data entries
14 entries across 14 versions & 2 rubygems