我想调试我的Rails应用程序使用
RestClient创建的请求.RestClient文档说:
To enable logging you can
set RestClient.log with a ruby Logger
or set an environment variable to avoid modifying the code (in this case you can use a file name,“stdout” or “stderr”):$RESTCLIENT_LOG=stdout path/to/my/program
Either produces logs like this:RestClient.get “07001”
=> 200 OK | text/html 250 bytes
RestClient.put “07001”,“payload”
=> 401 Unauthorized | application/xml 340 bytes
Note that these logs are valid Ruby,so you can paste them into the restclient shell or a >script to replay your sequence of rest calls.
如何将这些日志包含在我的Rails应用程序日志文件夹中?
解决方法
来自:
https://gist.github.com/jeremy/1383337
require 'restclient' # RestClient logs using << which isn't supported by the Rails logger,# so wrap it up with a little proxy object. RestClient.log = Object.new.tap do |proxy| def proxy.<<(message) Rails.logger.info message end end
原文地址:https://www.jb51.cc/ruby/267106.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。