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.

49 lines
1.4 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. logger.level = Hot::Constants.log_action_view ? :debug : :fatal
  10. end
  11. def render_partial(event)
  12. identifier = pathname(event.payload[:identifier])
  13. # logger.debug("Rendered partial #{identifier}", event.payload[:locals]) if identifier
  14. logger.debug("Rendered partial #{identifier}") if identifier
  15. end
  16. def render_template(event)
  17. layout = event.payload[:layout]
  18. return unless layout
  19. identifier = pathname(event.payload[:identifier])
  20. logger.debug { "Rendered template #{identifier}" } if identifier
  21. end
  22. def render_collection(event)
  23. identifier = pathname(event.payload[:identifier])
  24. count = event.payload[:count]
  25. cache_hits = event.payload[:cache_hits] || 0
  26. logger.debug { "Rendered collection #{identifier} (#{count} times, #{cache_hits} cached)" } if identifier
  27. end
  28. def render_layout(event)
  29. identifier = pathname(event.payload[:identifier])
  30. logger.debug { "Rendered layout #{identifier}" } if identifier
  31. end
  32. private
  33. def pathname(location)
  34. m = REGEX_BASEDIR.match(location)
  35. m[1] if m
  36. end
  37. end
  38. end
  39. end