Class: Sqreen::PerformanceNotifications::Log
- Inherits:
-
Object
- Object
- Sqreen::PerformanceNotifications::Log
show all
- Defined in:
- lib/sqreen/performance_notifications/log.rb
Overview
Log performances on the console
Class Method Summary
collapse
Class Method Details
.enable(facility = nil) ⇒ Object
28
29
30
31
32
|
# File 'lib/sqreen/performance_notifications/log.rb', line 28
def enable(facility = nil)
return unless @subid.nil?
@facility = facility
@subid = Sqreen::PerformanceNotifications.subscribe(&method(:log))
end
|
.event_name(rule, cb) ⇒ Object
24
25
26
|
# File 'lib/sqreen/performance_notifications/log.rb', line 24
def event_name(rule, cb)
"Callbacks/#{rule}/#{cb}"
end
|
.log(rule, cb, start, finish, meta) ⇒ Object
15
16
17
18
19
20
21
22
|
# File 'lib/sqreen/performance_notifications/log.rb', line 15
def log(rule, cb, start, finish, meta)
(@facility || Sqreen.log).debug do
meta_str = nil
meta_str = ": #{meta.inspect}" unless meta.empty?
event = event_name(rule, cb)
format('%s took %.2fms%s', event, (finish - start) * 1000, meta_str)
end
end
|