如何阻止mongoid 5在rspec中发送垃圾邮件

时间:2015-10-19 14:52:51

标签: mongoid

我试过了:

  Mongoid.logger = nil
  Mongo::Logger.logger = nil

没有运气,我仍然收到很多信息:

D, [2015-10-19T17:45:40.385610 #23054] DEBUG -- : MONGODB | Adding localhost:27017 to the cluster.
D, [2015-10-19T17:45:40.387634 #23054] DEBUG -- : MONGODB | localhost:27017 | mauka_test.find | STARTED | {"find"=>"system.namespaces", "filter"=>{:name=>{"$not"=>/\.system\.|\$/}}}
D, [2015-10-19T17:45:40.388258 #23054] DEBUG -- : MONGODB | localhost:27017 | mauka_test.find | SUCCEEDED | 0.000532895s
D, [2015-10-19T17:45:40.388739 #23054] DEBUG -- : MONGODB | localhost:27017 | mauka_test.delete | STARTED | {"delete"=>"mauka_metrics", "deletes"=>[{"q"=>{}, "limit"=>0}], "writeConcern"=>{"w"=>1}, "ordered"=>true}
D, [2015-10-19T17:45:40.389092 #23054] DEBUG -- : MONGODB | localhost:27017 | mauka_test.delete | SUCCEEDED | 0.000283895s

我错过了什么?

1 个答案:

答案 0 :(得分:1)

在spec / rails_helper.rb中,您可以增加mongo的记录器级别,如:

Mongo::Logger.logger.level = Logger::WARN

根据您的需要将WARN更改为INFO或FATAL。 DEBUG是默认值。