Using Native ActiveRecord Logger

Starting in Rails 5.2 there's a new setting to log ActiveRecord
queries making the LogQuerySource not needed anymore
This commit is contained in:
Espartaco Palma 2020-01-23 00:01:11 -08:00 committed by Henne Vogelsang
parent f50a92bf53
commit 2d17ce2667
No known key found for this signature in database
GPG key ID: 9D6164C2955FADE0
2 changed files with 1 additions and 18 deletions

View file

@ -113,5 +113,5 @@ Osem::Application.configure do
devise_config.ichain_test_mode = true devise_config.ichain_test_mode = true
end end
end end
config.active_record.verbose_query_logs = true
end end

View file

@ -1,17 +0,0 @@
# 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