Class: RediSearch::LogSubscriber

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.reset_runtimeObject

:nocov:



24
25
26
27
# File 'lib/redi_search/log_subscriber.rb', line 24

def self.reset_runtime
  rt, self.runtime = runtime, 0
  rt
end

.runtimeObject



19
20
21
# File 'lib/redi_search/log_subscriber.rb', line 19

def self.runtime
  Thread.current[:redi_search_runtime] ||= 0
end

.runtime=(value) ⇒ Object



15
16
17
# File 'lib/redi_search/log_subscriber.rb', line 15

def self.runtime=(value)
  Thread.current[:redi_search_runtime] = value
end

Instance Method Details

#action(event) ⇒ Object

:nocov:



30
31
32
33
34
35
36
37
38
# File 'lib/redi_search/log_subscriber.rb', line 30

def action(event)
  self.class.runtime += event.duration
  return unless logger.debug?

  command = command_string(event)
  debug_color = action_color(event.payload[:action])

  debug "  #{log_name(event)}  #{color(command, debug_color, bold: true)}"
end