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

Version Path
ar-octopus-0.9.0 lib/octopus/log_subscriber.rb
ar-octopus-0.8.6 lib/octopus/log_subscriber.rb
misha-ar-octopus-0.8.7 lib/octopus/log_subscriber.rb
misha-ar-octopus-0.8.5 lib/octopus/log_subscriber.rb
ar-octopus-0.8.5 lib/octopus/log_subscriber.rb
ar-octopus-0.8.4 lib/octopus/log_subscriber.rb
ar-octopus-0.8.3 lib/octopus/log_subscriber.rb
ar-octopus-0.8.2 lib/octopus/log_subscriber.rb
ar-octopus-0.8.1 lib/octopus/rails3/log_subscriber.rb
ar-octopus-0.8.0 lib/octopus/rails3/log_subscriber.rb
ar-octopus-0.7.0 lib/octopus/rails3/log_subscriber.rb
ar-octopus-0.6.1 lib/octopus/rails3/log_subscriber.rb
ar-octopus-0.6.0 lib/octopus/rails3/log_subscriber.rb
ar-octopus-0.5.0 lib/octopus/rails3/log_subscriber.rb