Class: ActiveClient::LogSubscriber

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.reset_runtimeObject

:nocov:



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

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

.runtimeObject



13
14
15
# File 'lib/active_client/log_subscriber.rb', line 13

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

.runtime=(value) ⇒ Object



9
10
11
# File 'lib/active_client/log_subscriber.rb', line 9

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

Instance Method Details

#request(event) ⇒ Object

:nocov:



24
25
26
27
28
29
30
31
32
# File 'lib/active_client/log_subscriber.rb', line 24

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

  log_name = color("#{event.payload[:name]} (#{event.duration.round(1)}ms)",
                   YELLOW, bold: true)

  debug "  #{log_name}  #{color(event.payload[:uri], YELLOW, bold: true)}"
end