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.

47 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. 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. logger.debug { "Rendered collection #{identifier}" } if identifier
  25. end
  26. def render_layout(event)
  27. identifier = pathname(event.payload[:identifier])
  28. logger.debug { "Rendered layout #{identifier}" } if identifier
  29. end
  30. private
  31. def pathname(location)
  32. m = REGEX_BASEDIR.match(location)
  33. m[1] if m
  34. end
  35. end
  36. end
  37. end