Cucumber / Savon省略或删除日志记录输出 [英] Cucumber / Savon omit or remove logging output

查看:182
本文介绍了Cucumber / Savon省略或删除日志记录输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在运行黄瓜测试时,我得到(除了测试结果)很多调试/日志相关的输出形式:

  D,[2013-03-06T12:21:38.911829#49031] DEBUG  - :SOAP请求:
D,[2013-03-06T12:21:38.911919#49031]调试 - Pragma:no-cache,SOAPAction:,Content-Type:text / xml; charset = UTF-8,Content-Length:1592
W,[2013-03-06T12:21:38.912360#49031] - :HTTPI使用httpclient适配器执行HTTP POST
D,[2013-03-06T12:21:39.410335#49031] DEBUG - :<?xml version =1.0encoding =UTF-8 ?>
< soap:Envelope
xmlns:xsi =http://www.w3.org/2001/XMLSchema-instance
...

有没有办法关闭此输出?我已尝试按照此帖和我的config_spec.rb文件中的说明是:

  requirespec_helper

describe Savon :: Config do

let(:config){
config = Savon :: Config.new
config._logger = Savon :: Logger.new
config.log_level =:error#更改日志级别
HTTPI.log = false#总共记录日志。
config

}

描述#clonedo
it克隆日志记录器do
logger = config.logger
clone = config.clone

logger.should_not equal(clone.logger)
end
end

允许更改记录器 do
logger = Logger.new(/ dev / null)
config.logger = logger
config._logger.subject.should equal(logger)
end

it允许改变日志级别do
Savon :: Request.log_level =:info
config.log_level =:error
config._logger.level.should = =:error
end

it允许启用/禁用日志记录do
config.log = false
config._logger.should be_a(Savon :: NullLogger )
config.log = false
config._logger.should be_a(Savon :: Logger)
end

end
解决方案


$ b / div>

通过查看 Savon API 的文档,您似乎可以停止日志记录通过做:

  Savon.configure do | config | 
config.log = false
end

上面的代码段可以放在您的 Cucumber World 功能/ support / env.rb ,以便在Cucumber中静默日志记录。


While running a cucumber test I am getting (in addition to the test results) a lot of debug/log related output in the form:

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" 
...

Is there a way to turn this output off? I have tried following the instructions in this post, and my config_spec.rb file is:

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

But the logging still showing when I run the cucumber tests.

解决方案

By looking at the documentation for the Savon API you seem to be able to silence the logging by doing:

Savon.configure do |config|
  config.log = false
 end

The snippet above could be put in your Cucumber World or in features/support/env.rb in order to silence the logging in Cucumber as well.

这篇关于Cucumber / Savon省略或删除日志记录输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆