【发布时间】:2015-01-07 05:05:41
【问题描述】:
我在工作文件中添加了以下 Rails 记录器。
@@logger = Logger.new "log/rest_client.log"
@@logger.level = Logger::DEBUG
end
begin
@@logger.debug "The request #{url}"
response = RestClient.get '#{url}'
@@logger.debug "Successful response #{response}"
rescue => e
@@logger.debug "Failure response #{e.message}"
end
我想用 logger(rest_client.log) 中的唯一 id 来识别请求和响应(成功或失败)。
现在日志是
D, [2014-12-09T14:27:18.576498 #29871] DEBUG -- : The request https://api.bitfinex.com/v1/symbols
D, [2014-12-09T14:27:21.547365 #29874] DEBUG -- :Successful response ["btcusd","ltcusd","ltcbtc","drkusd","drkbtc","th1btc"]
我想要一些对请求和响应都唯一的东西来识别它们属于同一个。
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-4 logging