Class: CassandraObject::LogSubscriber
- Inherits:
-
ActiveSupport::LogSubscriber
- Object
- ActiveSupport::LogSubscriber
- CassandraObject::LogSubscriber
- Defined in:
- lib/cassandra_object/log_subscriber.rb
Instance Method Summary collapse
- #cql(event) ⇒ Object
-
#initialize ⇒ LogSubscriber
constructor
A new instance of LogSubscriber.
- #odd? ⇒ Boolean
Constructor Details
#initialize ⇒ LogSubscriber
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
23 24 25 |
# File 'lib/cassandra_object/log_subscriber.rb', line 23 def odd? @odd_or_even = !@odd_or_even end |