Merge pull request #2631 from esparta/use_native_active_record_logger

Using Native ActiveRecord Logger
This commit is contained in:
Henne Vogelsang 2021-03-06 19:16:36 +01:00 committed by GitHub
commit 8e7cb18c36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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
end
end
config.active_record.verbose_query_logs = true
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