class Sqreen::PerformanceNotifications::Log

Log performances on the console

Public Class Methods

disable() click to toggle source
# File lib/sqreen/performance_notifications/log.rb, line 34
def disable
  return if @subid.nil?
  Sqreen::PerformanceNotifications.unsubscribe(@subid)
  @subid = nil
end
enable(facility = nil) click to toggle source
# 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) click to toggle source
# File lib/sqreen/performance_notifications/log.rb, line 24
def event_name(rule, cb)
  "Callbacks/#{rule}/#{cb}"
end
log(rule, cb, start, finish, meta) click to toggle source
# 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