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.

45 lines
1.3 KiB

  1. module Semantic
  2. module Subscribers
  3. # LogSubscriber for event_group :action_view
  4. class ActionView < LogSubscriber
  5. include AnsiColors
  6. REGEX_BASEDIR = %r{^#{Rails.root}/(.*)}
  7. def initialize(*) = super(:view)
  8. def render_partial(event)
  9. identifier = pathname(event.payload[:identifier])
  10. # logger.debug("Rendered partial #{identifier}", event.payload[:locals]) if identifier
  11. logger.debug("Rendered partial #{identifier}") if identifier
  12. end
  13. def render_template(event)
  14. layout = event.payload[:layout]
  15. return unless layout
  16. identifier = pathname(event.payload[:identifier])
  17. logger.debug { "Rendered template #{identifier}" } if identifier
  18. end
  19. def render_collection(event)
  20. identifier = pathname(event.payload[:identifier])
  21. count = event.payload[:count]
  22. cache_hits = event.payload[:cache_hits] || 0
  23. logger.debug { "Rendered collection #{identifier} (#{count} times, #{cache_hits} cached)" } if identifier
  24. end
  25. def render_layout(event)
  26. identifier = pathname(event.payload[:identifier])
  27. logger.debug { "Rendered layout #{identifier}" } if identifier
  28. end
  29. private
  30. def pathname(location)
  31. m = REGEX_BASEDIR.match(location)
  32. m[1] if m
  33. end
  34. end
  35. end
  36. end