Class: CassandraObject::LogSubscriber

Inherits:
ActiveSupport::LogSubscriber
  • Object
show all
Defined in:
lib/cassandra_object/log_subscriber.rb

Instance Method Summary collapse

Constructor Details

#initializeLogSubscriber

Returns a new instance of LogSubscriber.



3
4
5
6
# File 'lib/cassandra_object/log_subscriber.rb', line 3

def initialize
  super
  @odd_or_even = false
end

Instance Method Details

#cql(event) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/cassandra_object/log_subscriber.rb', line 8

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

#odd?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/cassandra_object/log_subscriber.rb', line 23

def odd?
  @odd_or_even = !@odd_or_even
end