Class: Lograge::ActiveRecordLogSubscriber

Inherits:
ActiveSupport::LogSubscriber
  • Object
show all
Defined in:
lib/lograge/sql/extension.rb

Instance Method Summary collapse

Instance Method Details

#sql(event) ⇒ Object



33
34
35
36
37
38
# File 'lib/lograge/sql/extension.rb', line 33

def sql(event)
  ActiveRecord::LogSubscriber.runtime += event.duration
  return if event.payload[:name] == 'SCHEMA'
  Thread.current[:lograge_sql_queries] ||= []
  Thread.current[:lograge_sql_queries] << ("#{event.payload[:name]} (#{event.duration.to_f.round(2)}) #{event.payload[:sql]}")
end