Class: XRayMachine::LogSubscriber
- Inherits:
-
ActiveSupport::LogSubscriber
- Object
- ActiveSupport::LogSubscriber
- XRayMachine::LogSubscriber
- Defined in:
- lib/x_ray_machine/log_subscriber.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.reset_runtimes ⇒ Object
7 8 9 |
# File 'lib/x_ray_machine/log_subscriber.rb', line 7 def self.reset_runtimes Thread.current["x_ray_machine_runtimes"] = nil end |
.runtimes ⇒ Object
3 4 5 |
# File 'lib/x_ray_machine/log_subscriber.rb', line 3 def self.runtimes Thread.current["x_ray_machine_runtimes"] ||= Hash.new{|k,_| 0} end |
Instance Method Details
#request(event) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/x_ray_machine/log_subscriber.rb', line 11 def request(event) group = event.payload[:group] config = XRayMachine::Config.for(group) self.class.runtimes[group] += event.duration name = config.title name += " CACHE" if event.payload[:cache] name = '%s (%.1fms)' % [name, event.duration] debug " #{color(name, config.color, true)} #{event.payload[:query]}" end |