pvincent
6 months ago
2 changed files with 40 additions and 3 deletions
@ -0,0 +1,31 @@ |
|||
# frozen_string_literal: true |
|||
|
|||
module ActiveRecord |
|||
class LogSubscriber < ActiveSupport::LogSubscriber |
|||
def log_query_source |
|||
source = query_source_location |
|||
|
|||
puts 'DEBUG logSubscriber monkeying' |
|||
|
|||
return unless source |
|||
|
|||
logger.debug(" ↳ #{source}") |
|||
end |
|||
|
|||
if Thread.respond_to?(:each_caller_location) |
|||
def query_source_location |
|||
Thread.each_caller_location do |location| |
|||
frame = backtrace_cleaner.clean_frame(location) |
|||
return frame if frame |
|||
end |
|||
nil |
|||
end |
|||
else |
|||
def query_source_location |
|||
backtrace_cleaner.clean(caller(1).lazy).first |
|||
end |
|||
end |
|||
end |
|||
end |
|||
|
|||
ActiveRecord::LogSubscriber.attach_to :active_record |
Write
Preview
Loading…
Cancel
Save
Reference in new issue