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

2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
  1. module Semantic
  2. module Subscribers
  3. # LogSubscriber for event_group :active_record
  4. class ActiveRecord < LogSubscriber
  5. include AnsiColors
  6. IGNORE_PAYLOAD_NAMES = %w[SCHEMA EXPLAIN].freeze
  7. def sql(event)
  8. name = event.payload[:name]
  9. return if IGNORE_PAYLOAD_NAMES.include?(name)
  10. if name.end_with?('Load')
  11. name = event.payload[:cached] ? "#{name} (cached)" : "#{name} (#{event.payload[:row_count]})"
  12. end
  13. name = colorize(name, TEXT_CYAN)
  14. sql = colorize(event.payload[:sql], TEXT_BLUE)
  15. logger.debug("#{name} #{sql}")
  16. end
  17. def instantiation(event)
  18. # class_name = event.payload[:class_name]
  19. # record_count = event.payload[:record_count]
  20. # logger.debug("instantiate #{class_name} #{record_count} times")
  21. end
  22. def strict_loading_violation(event) = any_hook event
  23. def start_transaction(event) = any_hook event
  24. def transaction(event) = any_hook event
  25. end
  26. end
  27. end