2010-06-24 07:23:43 -04:00
|
|
|
module ActionView
|
|
|
|
# = Action View Log Subscriber
|
|
|
|
#
|
|
|
|
# Provides functionality so that Rails can output logs from Action View.
|
|
|
|
class LogSubscriber < ActiveSupport::LogSubscriber
|
|
|
|
def render_template(event)
|
2011-06-24 15:01:57 -04:00
|
|
|
message = " Rendered #{from_rails_root(event.payload[:identifier])}"
|
2010-06-24 07:23:43 -04:00
|
|
|
message << " within #{from_rails_root(event.payload[:layout])}" if event.payload[:layout]
|
|
|
|
message << (" (%.1fms)" % event.duration)
|
2010-08-14 01:13:00 -04:00
|
|
|
info(message)
|
2010-06-24 07:23:43 -04:00
|
|
|
end
|
|
|
|
alias :render_partial :render_template
|
|
|
|
alias :render_collection :render_template
|
|
|
|
|
|
|
|
def logger
|
2012-01-18 12:05:36 -05:00
|
|
|
ActionView::Base.logger
|
2010-06-24 07:23:43 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def from_rails_root(string)
|
|
|
|
string.sub("#{Rails.root}/", "").sub(/^app\/views\//, "")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-06-27 18:46:57 -04:00
|
|
|
ActionView::LogSubscriber.attach_to :action_view
|