Sha256: 8b759a96d669d741eb15b4ff05f6624a091b04847b67474d9f7c069c7b8dbc2e

Contents?: true

Size: 1.87 KB

Versions: 10

Compression:

Stored size: 1.87 KB

Contents

module CassandraObject
  class LogSubscriber < ActiveSupport::LogSubscriber
    def add(event)
      name = '%s add (%.1fms)' % [event.payload[:column_family], event.duration]

      debug "  #{name}  #{event.payload[:key]}[#{event.payload[:column]}]#{event.payload[:sub_column] ? '[' + event.payload[:sub_column] + ']' : ''} by #{event.payload[:value]}"
    end

    def get(event)
      name = '%s get (%.1fms)' % [event.payload[:column_family], event.duration]
      
      debug "  #{name}  #{event.payload[:key]}"
    end

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

      debug "  #{name}  #{event.payload[:key]}[#{event.payload[:column]}]"
    end

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

      debug "  #{name}  (#{event.payload[:keys].size}) #{event.payload[:keys].join(" ")}"
    end

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

      message = "  #{name}  #{event.payload[:key]}"
      message << " #{Array(event.payload[:attributes]).inspect}" if event.payload[:attributes]

      debug message
    end

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

      debug "  #{name}  #{event.payload[:column_family]}"
    end

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

      debug "  #{name}  #{event.payload[:key]} #{event.payload[:attributes].inspect}"
    end

    def get_range(event)
      name = '%s get_range (%.1fms)' % [event.payload[:column_family], event.duration]
      
      debug "  #{name}  (#{event.payload[:count]}) '#{event.payload[:start]}' => '#{event.payload[:finish]}'"
    end
  end
end
CassandraObject::LogSubscriber.attach_to :cassandra_object

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
sessionm-cassandra_object-2.2.38 lib/cassandra_object/log_subscriber.rb
sessionm-cassandra_object-2.2.37 lib/cassandra_object/log_subscriber.rb
sessionm-cassandra_object-2.2.36 lib/cassandra_object/log_subscriber.rb
sessionm-cassandra_object-2.2.35 lib/cassandra_object/log_subscriber.rb
sessionm-cassandra_object-2.2.34 lib/cassandra_object/log_subscriber.rb
sessionm-cassandra_object-2.2.33 lib/cassandra_object/log_subscriber.rb
sessionm-cassandra_object-2.2.32 lib/cassandra_object/log_subscriber.rb
sessionm-cassandra_object-2.2.31 lib/cassandra_object/log_subscriber.rb
sessionm-cassandra_object-2.2.30 lib/cassandra_object/log_subscriber.rb
sessionm-cassandra_object-2.2.29 lib/cassandra_object/log_subscriber.rb