Sha256: def4cd63d0aafd4acb224de81dd639320209a721985bb5c05c909795ba561370

Contents?: true

Size: 615 Bytes

Versions: 34

Compression:

Stored size: 615 Bytes

Contents

module CassandraObject
  class LogSubscriber < ActiveSupport::LogSubscriber
    def initialize
      super
      @odd_or_even = false
    end

    def cql(event)
      payload = event.payload
      name = '%s (%.1fms)' % [payload[:name], event.duration]
      cql = payload[:cql].squeeze(' ')

      if odd?
        name = color(name, CYAN, true)
        cql  = color(cql, nil, true)
      else
        name = color(name, MAGENTA, true)
      end

      debug "  #{name}  #{cql}"
    end

    def odd?
      @odd_or_even = !@odd_or_even
    end
  end
end

CassandraObject::LogSubscriber.attach_to :cassandra_object

Version data entries

34 entries across 34 versions & 2 rubygems

Version Path
gotime-cassandra_object-4.11.5 lib/cassandra_object/log_subscriber.rb
gotime-cassandra_object-4.11.4 lib/cassandra_object/log_subscriber.rb
gotime-cassandra_object-4.11.3 lib/cassandra_object/log_subscriber.rb
gotime-cassandra_object-4.11.2 lib/cassandra_object/log_subscriber.rb
gotime-cassandra_object-4.11.1 lib/cassandra_object/log_subscriber.rb
gotime-cassandra_object-4.11.0 lib/cassandra_object/log_subscriber.rb
gotime-cassandra_object-4.10.5 lib/cassandra_object/log_subscriber.rb
gotime-cassandra_object-4.10.4 lib/cassandra_object/log_subscriber.rb
gotime-cassandra_object-4.10.3 lib/cassandra_object/log_subscriber.rb
gotime-cassandra_object-4.10.2 lib/cassandra_object/log_subscriber.rb
gotime-cassandra_object-4.10.1 lib/cassandra_object/log_subscriber.rb
cassandra_object_rails-0.0.1 lib/cassandra_object/log_subscriber.rb
gotime-cassandra_object-4.10.0 lib/cassandra_object/log_subscriber.rb
gotime-cassandra_object-4.9.2 lib/cassandra_object/log_subscriber.rb
gotime-cassandra_object-4.9.1 lib/cassandra_object/log_subscriber.rb
gotime-cassandra_object-4.9.0 lib/cassandra_object/log_subscriber.rb
gotime-cassandra_object-4.8.1 lib/cassandra_object/log_subscriber.rb
gotime-cassandra_object-4.8.0 lib/cassandra_object/log_subscriber.rb
gotime-cassandra_object-4.7.3 lib/cassandra_object/log_subscriber.rb
gotime-cassandra_object-4.7.2 lib/cassandra_object/log_subscriber.rb