如何使tail -f log / test.log可读

时间:2017-11-22 19:16:38

标签: ruby-on-rails testing logging

我是使用Rails进行功能测试的忠实粉丝。如果我能以可读的方式查看测试日志而不将所有内容压缩成一条大线,那么帮助调试真正令人敬畏的东西。

例如,如果测试失败,我会得到大约50行:

Could not log "render_template.action_view" event. NoMethodError: undefined method `example_group' for nil:NilClass ["/Users/***/.rvm/gems/ruby-2.3.0/gems/rspec-rails-3.6.0/lib/rspec/rails/view_rendering.rb:67:in `current_example_group'", "/Users/***/.rvm/gems/ruby-2.3.0/gems/rspec-rails-3.6.0/lib/rspec/rails/view_rendering.rb:71:in `render_template'", "/Users/***/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.3/lib/active_support/subscriber.rb:95:in `finish'", "/Users/***/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.3/lib/active_support/log_subscriber.rb:83:in `finish'", "/Users/***/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.3/lib/active_support/notifications/fanout.rb:102:in `finish'", "/Users/***/.rvm/gems

有可能吗?我尝试过像better_logging,漂亮的印刷品等宝石,但没有运气。

1 个答案:

答案 0 :(得分:0)

我猜您可以使用built in Logger class格式化显示的日志消息。如果已经使用它,请尝试将日志级别更改为debug。