gpt4 book ai didi

ruby-on-rails - 隐藏 Rails 日志中的局部渲染

转载 作者:行者123 更新时间:2023-12-03 19:53:39 28 4
gpt4 key购买 nike

我相信 Rails 登录生产的默认行为是不输出所有部分的渲染。这应该登录开发而不是生产。

但是,我在生产中看到了这个,我不知道如何删除它。我的日志太吵了。我的生产环境是 Heroku 运行 Unicorn 并使用 Papertrail 查看我的日志。我知道 Unicorn 用日志做了一些奇怪的事情,为了让它们首先正常工作,我必须将它添加到我的 production.rb 中:

  config.logger = Logger.new(STDOUT)
config.logger.level = Logger.const_get('INFO')

(此处解释: http://help.papertrailapp.com/kb/configuration/unicorn)

但即使使用 log_level INFO,我在所有日志中也看到了这些大块:
Jun 25 22:15:15 tacktile app/web.1:    Rendered photos/pieces/_caption.html.erb (0.7ms) 
Jun 25 22:15:15 tacktile app/web.1: Rendered photos/pieces/_rights.html.erb (2.1ms)
Jun 25 22:15:15 tacktile app/web.1: Rendered photos/pieces/_category.html.erb (4.8ms)
Jun 25 22:15:15 tacktile app/web.1: Rendered photos/pieces/_caption.html.erb (0.3ms)
Jun 25 22:15:15 tacktile app/web.1: Rendered photos/pieces/_rights.html.erb (0.4ms)
Jun 25 22:15:15 tacktile app/web.1: Rendered photos/pieces/_category.html.erb (4.4ms)
Jun 25 22:15:15 tacktile app/web.1: Rendered photos/pieces/_caption.html.erb (0.3ms)
Jun 25 22:15:15 tacktile app/web.1: Rendered photos/pieces/_rights.html.erb (0.3ms)
Jun 25 22:15:15 tacktile app/web.1: Rendered photos/pieces/_category.html.erb (1.8ms)
Jun 25 22:15:15 tacktile app/web.1: Rendered photos/pieces/_caption.html.erb (0.4ms)
Jun 25 22:15:15 tacktile app/web.1: Rendered photos/pieces/_rights.html.erb (4.6ms)
Jun 25 22:15:15 tacktile app/web.1: Rendered photos/pieces/_category.html.erb (2.1ms)
Jun 25 22:15:15 tacktile app/web.1: Rendered photos/pieces/_caption.html.erb (0.3ms)
Jun 25 22:15:15 tacktile app/web.1: Rendered photos/pieces/_rights.html.erb (0.4ms)
Jun 25 22:15:15 tacktile app/web.1: Rendered photos/pieces/_category.html.erb (4.1ms)
Jun 25 22:15:15 tacktile app/web.1: Rendered photos/pieces/_caption.html.erb (0.2ms)
Jun 25 22:15:15 tacktile app/web.1: Rendered photos/pieces/_rights.html.erb (1.8ms)
Jun 25 22:15:15 tacktile app/web.1: Rendered photos/pieces/_category.html.erb (6.0ms)
Jun 25 22:15:15 tacktile app/web.1: Rendered photos/pieces/_caption.html.erb (0.5ms)
Jun 25 22:15:15 tacktile app/web.1: Rendered photos/pieces/_rights.html.erb (0.8ms)
Jun 25 22:15:15 tacktile app/web.1: Rendered photos/pieces/_category.html.erb (1.9ms)
Jun 25 22:15:15 tacktile app/web.1: Rendered photos/pieces/_caption.html.erb (0.3ms)
Jun 25 22:15:15 tacktile app/web.1: Rendered photos/pieces/_rights.html.erb (0.7ms)

最佳答案

这很常见,以至于在 纸轨 通知您记录峰值的电子邮件,有一个链接与这个确切的例子。
This is the link .
我稍微调整了正则表达式:

/\A\s{3}Rendered \w+\/_.+\.erb \(\d+\.\d+ms\)\z/
PS:我总是觉得奇怪的是它们首先是在信息级别打印的。

关于ruby-on-rails - 隐藏 Rails 日志中的局部渲染,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17312076/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com