Pha*_*ani 4 actionview ruby-on-rails-3.2
在rails 3.2.0中,是否可以在生产环境中关闭用于在ActionView :: LogSubscriber中呈现视图的rails日志记录.
目前只有我发现supress的方法是对它进行修补并通过以下方式增加日志级别进行调试.有没有更好的方法来执行此操作或任何配置?
module ActionView
class LogSubscriber
def render_template(event)
message = "Rendered #{from_rails_root(event.payload[:identifier])}"
message << " within #{from_rails_root(event.payload[:layout])}" if event.payload[:layout]
message << (" (%.1fms)" % event.duration)
debug(message)
end
alias :render_partial :render_template
alias :render_collection :render_template
end
end
Run Code Online (Sandbox Code Playgroud)
小智 17
ActionView使用ActiveSupport :: Notifications和ActiveSupport :: LogSubscriber来检测其事件,并使其从日志中静音就像在环境文件中包含以下内容一样简单:
%w{render_template render_partial render_collection}.each do |event|
ActiveSupport::Notifications.unsubscribe "#{event}.action_view"
end
Run Code Online (Sandbox Code Playgroud)
干杯!
| 归档时间: |
|
| 查看次数: |
1136 次 |
| 最近记录: |