You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

32 lines
1012 B

module Semantic
module Subscribers
# LogSubscriber for event_group :active_record
class ActiveRecord < LogSubscriber
include AnsiColors
IGNORE_PAYLOAD_NAMES = %w[SCHEMA EXPLAIN].freeze
def sql(event)
name = event.payload[:name]
return if IGNORE_PAYLOAD_NAMES.include?(name)
if name.end_with?('Load')
name = event.payload[:cached] ? "#{name} (cached)" : "#{name} (#{event.payload[:row_count]})"
end
name = colorize(name, TEXT_CYAN)
sql = colorize(event.payload[:sql], TEXT_BLUE)
logger.debug("#{name} #{sql}")
end
def instantiation(event)
# class_name = event.payload[:class_name]
# record_count = event.payload[:record_count]
# logger.debug("instantiate #{class_name} #{record_count} times")
end
def strict_loading_violation(event) = any_hook event
def start_transaction(event) = any_hook event
def transaction(event) = any_hook event
end
end
end