Skip to content

Instantly share code, notes, and snippets.

@derwiki
Created October 23, 2015 18:28
Show Gist options
  • Save derwiki/f051bb53025ed942e297 to your computer and use it in GitHub Desktop.
Save derwiki/f051bb53025ed942e297 to your computer and use it in GitHub Desktop.
Class.new(ActiveSupport::LogSubscriber) do
def sql(event)
return
query = event.payload[:sql]
if query =~ /SELECT/
Rails.logger.info "Traced query: #{query}"
Rails.logger.info '!stacktrace!begin'
# Rails.logger.info Rails.backtrace_cleaner.clean(caller).join("\n")
Rails.logger.info Rails.backtrace_cleaner.clean(caller).first
Rails.logger.info '!stacktrace!end'
end
end
end.attach_to :active_record
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment