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.
|
|
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 start_transaction(event) short_uuid = short_uuid(event.payload[:transaction].uuid) logger.info("TRANSACTION Begin #{short_uuid}") end
def transaction(event) outcome = event.payload[:outcome] short_uuid = short_uuid(event.payload[:transaction].uuid) logger.info("TRANSACTION #{outcome.capitalize} #{short_uuid}") end
def instantiation(event); end
def strict_loading_violation(event) = any_hook event
private
def short_uuid(uuid) = uuid.split('-').first end end end
|