mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
17 lines
496 B
Ruby
17 lines
496 B
Ruby
# http://www.jkfill.com/2015/02/14/log-which-line-caused-a-query/
|
|
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
|