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

module Semantic
module Subscribers
# LogSubscriber for event_group :action_view
class ActionView < LogSubscriber
include AnsiColors
REGEX_BASEDIR = %r{^#{Rails.root}/(.*)}
def initialize(*) = super(:view)
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