Sha256: 2a895074ad59471044fb82ad8f6009a62b2b65405f286db53fa8cc1714cdd691

Contents?: true

Size: 662 Bytes

Versions: 18

Compression:

Stored size: 662 Bytes

Contents

module DbCharmer
  module ActiveRecord
    module LogSubscriber

      def self.included(base)
        base.send(:attr_accessor, :connection_name)
        base.alias_method_chain :sql, :connection_name
        base.alias_method_chain :debug, :connection_name
      end

      def sql_with_connection_name(event)
        self.connection_name = event.payload[:connection_name]
        sql_without_connection_name(event)
      end

      def debug_with_connection_name(msg)
        conn = connection_name ? color("  [#{connection_name}]", ActiveSupport::LogSubscriber::BLUE, true) : ''
        debug_without_connection_name(conn + msg)
      end

    end
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
db-charmer-1.9.1 lib/db_charmer/rails3/active_record/log_subscriber.rb
db-charmer-1.9.0 lib/db_charmer/rails3/active_record/log_subscriber.rb
db-charmer-1.8.4 lib/db_charmer/rails3/active_record/log_subscriber.rb
db-charmer-1.8.3 lib/db_charmer/rails3/active_record/log_subscriber.rb
db-charmer-1.8.2 lib/db_charmer/rails3/active_record/log_subscriber.rb
db-charmer-1.8.1 lib/db_charmer/rails3/active_record/log_subscriber.rb
db-charmer-1.8.0 lib/db_charmer/rails3/active_record/log_subscriber.rb
db-charmer-1.8.0.pre1 lib/db_charmer/rails3/active_record/log_subscriber.rb
yam-db-charmer-1.7.4.14 lib/db_charmer/rails3/active_record/log_subscriber.rb
yam-db-charmer-1.7.4.13 lib/db_charmer/rails3/active_record/log_subscriber.rb
yam-db-charmer-1.7.4.10 lib/db_charmer/rails3/active_record/log_subscriber.rb
yam-db-charmer-1.7.4.9 lib/db_charmer/rails3/active_record/log_subscriber.rb
yam-db-charmer-1.7.4.8 lib/db_charmer/rails3/active_record/log_subscriber.rb
yam-db-charmer-1.7.4.0 lib/db_charmer/rails3/active_record/log_subscriber.rb
yam-db-charmer-1.7.01 lib/db_charmer/rails3/active_record/log_subscriber.rb
db-charmer-1.7.1 lib/db_charmer/rails3/active_record/log_subscriber.rb
db-charmer-1.7.0 lib/db_charmer/rails3/active_record/log_subscriber.rb
db-charmer-1.7.0.pre7 lib/db_charmer/rails3/active_record/log_subscriber.rb