Вопрос по ruby-on-rails – Ведение журнала RestClient в приложении Rails

6

Я хочу отладить запрос, с которым мое приложение 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 "http://some/resource"

=> 200 OK | text/html 250 bytes

RestClient.put "http://some/resource", "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?

Ваш Ответ

4   ответа
4

config/initializers:
RestClient.log = "log / a_log_file.log"
Или просто положить последний в консоли

https://github.com/adelevie/rest-client/commit/5a7ed325eaa091809141d3ef6e31087569614e9d

0

::RestClient.log = Rails.logger

13

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
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceededconfig/initializers/
1

https://github.com/uswitch/rest-client-logger

Он работает "из коробки", просто добавив "gem" rest-client-logger "& quot; в ваш Gemfile.

Похожие вопросы