我正在使用 RighAWS gem,并在 http 级别进行模拟,以便在我的测试中执行 RightAWS 代码。

发生这种情况时,我得到以下输出
....New RightAws::S3Interface using per_request-connection modeOpening new HTTP connection to s3.amazonaws.com:80.New RightAws::S3Interface using per_request-connection mode.
即使所有测试都通过了,当我确实有错误时,由于这个输出,它更难扫描它们。有什么好的方法可以让它静音吗?

最佳答案

您可以使用空设备进行日志记录:

s3 = RightAws::S3Interface.new(access_key, secret_key, {:port => 80, :protocol => 'http', :logger => Logger.new('/dev/null')})  //on unix system
s3 = RightAws::S3Interface.new(access_key, secret_key, {:port => 80, :protocol => 'http', :logger => Logger.new('NUL')})  //on windows

关于ruby - 运行测试时如何使以下 RightAWS 消息静音,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/1803352/

10-11 08:02