Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capistrano log level

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.

like image 284
Jey Balachandran Avatar asked Feb 24 '14 01:02

Jey Balachandran


Video Answer


1 Answers

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
like image 58
Sergey Evstifeev Avatar answered Sep 17 '22 18:09

Sergey Evstifeev