def self.install_logger(db_connection, config)
if config[:logger]
if config[:logger].respond_to?(:debug)
logger = config[:logger]
else
logger = ActiveSupport::BufferedLogger.new(config[:logger])
end
db_connection.instance_variable_set :@logger, logger
if ActiveSupport.const_defined?(:Notifications)
connection_object_id = db_connection.object_id
db_connection.log_subscriber = ActiveSupport::Notifications.subscribe("sql.active_record") do |name, start, finish, id, payload|
if payload[:connection_id] == connection_object_id and logger.debug?
logger.debug payload[:sql].squeeze(" ")
end
end
end
end
end