Ruby Savon Gem change logging configuration

一个人想着一个人 提交于 2020-02-03 16:17:44

问题


I've tried changing the logging on Savon when running it against a WSDL, but have been unsuccessful in changing the logging level.

I read the docs: http://rubiii.github.com/savon/#global_configuration

I did this:

Savon.configure do |config|
  config.log = false            # disable logging
  config.log_level = :info      # changing the log level
  config.logger = Rails.logger  # using the Rails logger
end

And it complains about not knowing what configure means.. any ideas?


回答1:


This documentation you linked is for savon 0.8, you may be using an older version. When in doubt, go to the source code (path is platform-dependent) and check how the code/test do it:

$ cd /usr/lib/ruby/gems/1.8/gems/savon-0.7.8
$ grep -lr log_level * 
lib/savon/logger.rb
spec/savon/request_spec.rb
$ cat spec/savon/request_spec.rb
...
Savon::Request.log_level = :info
...



回答2:


At least as of gem 'savon', '~> 2.3.0', you can add the configuration keys when instantiating the client.

client = Savon.client(
    log_level: :debug,
    log: true,
    pretty_print_xml: true,
    wsdl: 'http://ws.cdyne.com/emailverify/Emailvernotestemail.asmx?wsdl'
)


来源:https://stackoverflow.com/questions/4217783/ruby-savon-gem-change-logging-configuration

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!