Class: Datapathy::LogSubscriber

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.reset_runtimeObject



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

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

.runtimeObject



11
12
13
# File 'lib/datapathy/log_subscriber.rb', line 11

def self.runtime
  Thread.current["datapathy_query_runtime"] ||= 0
end

.runtime=(value) ⇒ Object



7
8
9
# File 'lib/datapathy/log_subscriber.rb', line 7

def self.runtime=(value)
  Thread.current["datapathy_query_runtime"] = value
end

Instance Method Details

#query(event) ⇒ Object



20
21
22
23
# File 'lib/datapathy/log_subscriber.rb', line 20

def query(event)
  self.class.runtime += event.duration
  debug("Datapathy: %s (%.1fms) %s" % [event.payload[:name], event.duration, event.payload[:query]])
end