在Rails日志中,我们可以看到这些数据。
I, [2023-04-03T18:04:57.968359 #77096] INFO -- : Started GET "/" for ::1 at 2023-04-03 18:04:57 +0100
D, [2023-04-03T18:04:57.991136 #77096] DEBUG -- : ActiveRecord::SchemaMigration Pluck (0.2ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` ORDER BY `schema_migrations`.`version` ASC
I, [2023-04-03T18:04:58.011691 #77096] INFO -- : Processing by HomeController#index as HTML
D, [2023-04-03T18:04:58.017021 #77096] DEBUG -- : Rendering layout layouts/application.html.erb
D, [2023-04-03T18:04:58.017077 #77096] DEBUG -- : Rendering home/index.html.erb within layouts/application
I, [2023-04-03T18:04:58.018070 #77096] INFO -- : Rendered home/index.html.erb within layouts/application (Duration: 1.0ms | Allocations: 922)
I, [2023-04-03T18:04:58.054433 #77096] INFO -- : Rendered layout layouts/application.html.erb (Duration: 37.4ms | Allocations: 60188)
I, [2023-04-03T18:04:58.054628 #77096] INFO -- : Completed 200 OK in 43ms (Views: 38.8ms | ActiveRecord: 0.0ms | Allocations: 65440)
我想看到视图文件的完整路径,当它被渲染时。
因此,我希望它不是Rendered home/index.html.erb
,而是Rendered app/views/home/index.html.erb
我如何才能做到这一点?
目前我在config/environments/development.rb中对logger的设置是这样的。
config.log_level = :debug
config.log_formatter = Logger::Formatter.new
1条答案
按热度按时间0yycz8jy1#
您可以对
ActionView::LogsSubscriber
类中定义的名为from_rails_root
的私有方法进行Monkey修补,该方法生成视图文件路径:或者,您可以通过创建自定义日志记录器类来覆盖操作视图的日志记录器配置: