Class: Console::Adapter::Rails::ActiveRecord::LogSubscriber
- Inherits:
-
ActiveSupport::LogSubscriber
- Object
- ActiveSupport::LogSubscriber
- Console::Adapter::Rails::ActiveRecord::LogSubscriber
- Defined in:
- lib/console/adapter/rails/active_record.rb
Constant Summary collapse
- IGNORE_PAYLOAD_NAMES =
["SCHEMA", "EXPLAIN", "TRANSACTION"]
Instance Method Summary collapse
-
#sql(event) ⇒ Object
Log an ActiveRecord sql event.
Instance Method Details
#sql(event) ⇒ Object
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.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/console/adapter/rails/active_record.rb', line 26 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 |