如何禁用ERB调试输出

时间:2013-12-03 02:03:53

标签: ruby logging erb

我正在将ERB用于CLI应用程序。如何禁用调试输出?每次运行使用ERB的命令时,每次找到变量时都会收到调试信息。

DEBUG: 2013-12-02 17:59:48 -0800: Looking for data source Users/tjbiddle/Projects/gh/packaging/puppet/hieradata/beta
DEBUG: 2013-12-02 17:59:48 -0800: Found debug in Users/tjbiddle/Projects/gh/packaging/puppet/hieradata/beta
DEBUG: 2013-12-02 17:59:48 -0800: Looking up stateConnectionString in YAML backend
DEBUG: 2013-12-02 17:59:48 -0800: Looking for data source Users/tjbiddle/Projects/gh/packaging/puppet/hieradata/beta
DEBUG: 2013-12-02 17:59:48 -0800: Found stateConnectionString in Users/tjbiddle/Projects/gh/packaging/puppet/hieradata/beta

编辑:

模板工作 - 它只是不是日志记录,这是我在下面实例化ERB对象的方式。

    # Load the template into ERB.
    web_config = ERB.new(web_config_content)

    # Print the templated file.
    hb = HieraBinding.new(handler.project_root, environment)
    File.open(destination, 'w+') { |file| file.write(web_config.result(hb.get_binding)) }

1 个答案:

答案 0 :(得分:1)

正如@mechanicalfish建议的那样,ERB以外的东西正在记录DEBUG语句。

具体来说,似乎hiera gem是这些陈述的来源。

您应该可以通过插入NO-OP Logger来覆盖此日志记录。查看sample configuration