Last active
August 18, 2018 21:04
-
-
Save rbraaf/aed4b0560ae974fa310c to your computer and use it in GitHub Desktop.
Show lines for slow queries
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
| # Add mixin to /config/initializers/ | |
| module LogQuerySource | |
| def debug(*args, &block) | |
| return unless super | |
| backtrace = Rails.backtrace_cleaner.clean caller | |
| relevant_caller_line = backtrace.detect do |caller_line| | |
| !caller_line.include?('/initializers/') | |
| end | |
| if relevant_caller_line | |
| logger.debug(" ↳ #{ relevant_caller_line.sub("#{ Rails.root }/", '') }") | |
| end | |
| end | |
| end | |
| ActiveRecord::LogSubscriber.send :prepend, LogQuerySource |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment