防止在控制台上打印日志

时间:2012-11-20 03:47:23

标签: ruby selenium-webdriver

我正在使用Ruby Selenium-webdriver编写脚本。运行脚本后,我在控制台上收到以下日志 -

 LOG addons.manager: Application has been upgraded
 LOG addons.xpi: startup
 LOG addons.xpi: Skipping unavailable install location app-system-local
 LOG addons.xpi: Skipping unavailable install location app-system-share
 LOG addons.xpi: checkForChanges
 LOG addons.xpi-utils: Opening database
 LOG addons.xpi-utils: Creating database schema
 LOG addons.xpi: New add-on fxdriver@googlecode.com installed in app-profile
 LOG addons.xpi: New add-on {972ce4c6-7e08-4474-a285-3208198ce6fd} installed in app-global
 LOG addons.xpi: New add-on {BBDA0591-3099-440a-AA10-41764D9DB4DB} installed in winreg-app-global
 LOG addons.xpi: New add-on fiddlerhook@fiddler2.com installed in winreg-app-global
 LOG addons.xpi: Updating database with changes to installed add-ons
 LOG addons.xpi-utils: Updating add-on states
 LOG addons.xpi-utils: Writing add-ons list
 LOG addons.xpi: shutdown
 LOG addons.xpi-utils: shutdown
 LOG addons.xpi-utils: Database closed
 LOG addons.xpi: startup
 LOG addons.xpi: Skipping unavailable install location app-system-local
 LOG addons.xpi: Skipping unavailable install location app-system-share
 LOG addons.xpi: checkForChanges
 LOG addons.xpi: No changes found

我不希望这些日志打印在控制台上,我只想要我的程序返回到STDOUT,在控制台上打印。有什么方法可以阻止Ruby中的这些日志吗?在Python中,我们可以使用以下 -

来完成此操作
import traceback
Settings.ActionLogs=False
Settings.InfoLogs=False
Settings.DebugLogs=False

1 个答案:

答案 0 :(得分:0)

首先在控制台中运行此命令,然后运行代码:

ActiveRecord::Base.logger = nil

这将在控制台中运行。