如何记录使用httparty发送的请求?
HTTParty.post(
@application_url,
:headers => {
"Accept" => "application/json",
"Content-Type" => "application/json; charset=utf-8"
},
:body => {
"ApplicationProfileId" => application.applicationProfileId
}.to_json
)发布于 2015-01-31 07:58:59
在类级别使用debug_output:
class Foo
include HTTParty
debug_output $stdout
end或每个请求
response = HTTParty.post(url, :body => body, :debug_output => $stdout)发布于 2014-03-15 04:14:32
使用类级debug_output方法设置发送调试信息的输出流。
发布于 2019-08-12 19:45:19
您可以使用内置的记录器:
my_logger = Rails.logger || Logger.new # use what you like
my_logger.info "The default formatter is :apache. The :curl formatter can also be used."
my_logger.info "You can tell which method to call on the logger too. It is info by default."
HTTParty.get "http://google.com", logger: my_logger, log_level: :debug, log_format: :curlhttps://stackoverflow.com/questions/22414803
复制相似问题