有没有办法让Rails只显示SQL执行时间而不是自己显示SQL查询?
答案 0 :(得分:0)
我提出了这个解决方案
1 class TimeLogFormatter < Logger
2 def format_message(severity, timestamp, progname, msg)
3 time_capture = msg.match /\[\d+m\w.*\([\d\.]+ms\)/
4 if time_capture
5 "\e#{time_capture}\e[0m\n"
6 end
7 end
8 end
9 ActiveRecord::Base.logger = TimeLogFormatter.new(STDOUT)