module Semantic module Subscribers # LogSubscriber for event_group :action_view class ActionView < LogSubscriber include AnsiColors REGEX_BASEDIR = %r{^#{Rails.root}/(.*)} attr_reader :logger def render_partial(event) identifier = pathname(event.payload[:identifier]) # logger.debug("Rendered partial #{identifier}", event.payload[:locals]) if identifier logger.debug("Rendered partial #{identifier}") if identifier end def render_template(event) layout = event.payload[:layout] return unless layout identifier = pathname(event.payload[:identifier]) logger.debug { "Rendered template #{identifier}" } if identifier end def render_collection(event) identifier = pathname(event.payload[:identifier]) count = event.payload[:count] cache_hits = event.payload[:cache_hits] || 0 logger.debug { "Rendered collection #{identifier} (#{count} times, #{cache_hits} cached)" } if identifier end def render_layout(event) identifier = pathname(event.payload[:identifier]) logger.debug { "Rendered layout #{identifier}" } if identifier end private def pathname(location) m = REGEX_BASEDIR.match(location) m[1] if m end end end end