Console::Adapter::Rails SourceConsoleAdapterRailsActiveRecordLogSubscriber

class LogSubscriber

Definitions

def sql(event)

Log an ActiveRecord sql event.

Includes the following fields:

  • subject: "process_action.action_controller"
  • sql: The SQL query itself.
  • name: The name of the query.
  • binds: The bind parameters as an array of name-value pairs.
  • allocations: The number of allocations performed.
  • duration: The total time spent processing the request in milliseconds.

Implementation

def sql(event)
	return if IGNORE_PAYLOAD_NAMES.include?(event.payload[:name])
	
	payload = event.payload.dup
	
	# We don't want to dump the connection:
	connection = payload.delete(:connection)
	
	update_binds(payload)
	
	payload[:allocations] = event.allocations
	payload[:duration] = event.duration
	
	Console.logger.info(event.name, **payload)
end