Skip to content

Instantly share code, notes, and snippets.

@lann
Created August 22, 2013 22:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lann/6313547 to your computer and use it in GitHub Desktop.
Save lann/6313547 to your computer and use it in GitHub Desktop.
Class.new(ActiveSupport::LogSubscriber) do
def sql(event)
query = event.payload[:sql]
if query.length > 10_000
Rails.logger.info "Large query: #{query}"
Rails.logger.info '!stacktrace!begin'
Rails.logger.info Rails.backtrace_cleaner.clean(caller).join("\n")
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