oba*_*iro 5 ruby logging cucumber savon
在运行黄瓜测试时,我得到了(除了测试结果)以下形式的许多调试/日志相关输出:
D, [2013-03-06T12:21:38.911829 #49031] DEBUG -- : SOAP request:
D, [2013-03-06T12:21:38.911919 #49031] DEBUG -- : Pragma: no-cache, SOAPAction: "", Content-Type: text/xml;charset=UTF-8, Content-Length: 1592
W, [2013-03-06T12:21:38.912360 #49031] WARN -- : HTTPI executes HTTP POST using the httpclient adapter
D, [2013-03-06T12:21:39.410335 #49031] DEBUG -- : <?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
...
Run Code Online (Sandbox Code Playgroud)
有没有办法关掉这个输出?我试过按照这篇文章中的说明操作,我的config_spec.rb文件是:
require "spec_helper"
describe Savon::Config do
let(:config) {
config = Savon::Config.new
config._logger = Savon::Logger.new
config.log_level = :error # changing the log level
HTTPI.log = false # to total silent the logging.
config
}
describe "#clone" do
it "clones the logger" do
logger = config.logger
clone = config.clone
logger.should_not equal(clone.logger)
end
end
it "allows to change the logger" do
logger = Logger.new("/dev/null")
config.logger = logger
config._logger.subject.should equal(logger)
end
it "allows to change the log level" do
Savon::Request.log_level = :info
config.log_level = :error
config._logger.level.should == :error
end
it "allows to enable/disable logging" do
config.log = false
config._logger.should be_a(Savon::NullLogger)
config.log = false
config._logger.should be_a(Savon::Logger)
end
end
Run Code Online (Sandbox Code Playgroud)
但是,当我进行黄瓜测试时,记录仍然显示.
Kev*_*erg 10
通过查看Savon API的文档,您似乎可以通过执行以下操作来使日志记录静音:
Savon.configure do |config|
config.log = false
end
Run Code Online (Sandbox Code Playgroud)
上面的片段可以放在你的黄瓜世界或者features/support/env.rb为了使黄瓜的记录变得沉默.
| 归档时间: |
|
| 查看次数: |
2667 次 |
| 最近记录: |