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.

48 lines
1.3 KiB

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