创建用于rails请求分析器的脚本的最佳方法是什么?
-
02-07-2019 - |
题
rails脚本 script / performance / request
需要会话脚本,生成此会话脚本的最佳方法是什么?
解决方案
将此代码添加到application.rb文件
before_filter :benchmark_log
def benchmark_log
File.open("request_log.txt","a") do |f|
f.puts request.method.to_s + " '" + request.request_uri + "', " + params.except(:action).except(:controller).inspect.gsub(/(^\{|\}$)/,"")
end
end
然后您可以在浏览器中访问多个页面,会话脚本将写入应用程序根目录中的request_log.txt文件
不隶属于 StackOverflow