-
-
Save sahidursuman/5d3b85804d96a8bad389c806d4c83ada to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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