Class: SQLSubscriber

Inherits:
CustomLogSpace::BaseSubscriber show all
Defined in:
lib/custom_log_space/subscribers/sql_subscriber.rb

Overview

SQLSubscriber logs SQL related events for CustomLogSpace. It extends BaseSubscriber to make use of its logging capabilities.

Instance Method Summary collapse

Methods inherited from CustomLogSpace::BaseSubscriber

#process_action, #start_processing

Instance Method Details

#sql(event) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/custom_log_space/subscribers/sql_subscriber.rb', line 6

def sql(event)
  payload = event.payload
  name = payload[:name]
  sql = payload[:sql]
  duration = event.duration.round(1)
  message = "#{name} (#{duration}ms) #{sql}"
  log_message(message)
end