Capistrano日志级别 [英] Capistrano log level

查看:80
本文介绍了Capistrano日志级别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将Capistrano配置的日志级别设置为error,以防止产生冗长的输出.在deploy.rb中,我添加了set :log_level, :error.这很好用.但是,当我通过execute运行命令时,由于它是在DEBUG的日志级别下编写的,因此不会打印出来.如何获得execute命令的输出以进行打印?我可以结合使用captureputs来输出它,但是当我必须流式传输日志时,这无济于事.

I've set my Capistrano configuration's log level to error to prevent verbose output. In deploy.rb I've added set :log_level, :error. This works great. However, when I run commands via execute, it isn't printed as it's being written under the log level of DEBUG. How can I get the output of execute commands to be printed out? I am able to use capture with the combination of puts to output it, but this doesn't help when I have to stream the logs.

推荐答案

您可以通过在deploy.rb文件中定义以下方法来做到这一点:

You can do this by defining the following method in your deploy.rb file:

def with_verbosity(verbosity_level)
  old_verbosity = SSHKit.config.output_verbosity
  begin
    SSHKit.config.output_verbosity = verbosity_level
    yield
  ensure
    SSHKit.config.output_verbosity = old_verbosity
  end
end

然后简单地这样称呼它:

Then simply call it like this:

with_verbosity(Logger::DEBUG) do
  execute "./blah.sh"
end

这篇关于Capistrano日志级别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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