lib/lograge/sql.rb in lograge-sql-1.2.0 vs lib/lograge/sql.rb in lograge-sql-1.3.0
- old
+ new
@@ -1,9 +1,10 @@
# frozen_string_literal: true
require 'lograge/sql/version'
+# Main Lograge module
module Lograge
# Main gem module
module Sql
class << self
# Format SQL log
@@ -20,11 +21,15 @@
# Disable existing ActiveRecord logging
ActiveSupport::LogSubscriber.log_subscribers.each do |subscriber|
Lograge.unsubscribe(:active_record, subscriber) if subscriber.is_a?(ActiveRecord::LogSubscriber)
end
+
+ Lograge::ActiveRecordLogSubscriber.attach_to :active_record
end
+ # Gets the store, preferring RequestStore if the gem is found.
+ # @return [Hash, Thread] the RequestStore or the current Thread.
def store
defined?(RequestStore) ? RequestStore.store : Thread.current
end
private