Skip to content

Commit

Permalink
Introduce debug? method for log filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
robd committed May 26, 2015
1 parent 82a11f2 commit 59a0296
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/airbrussh/formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ def write(obj)
print_line "#{clock} #{blue(new_rake_task)}"
end

return if debug?(obj)

case obj
when SSHKit::Command then write_command(obj)
when SSHKit::LogMessage then write_log_message(obj)
Expand All @@ -88,6 +90,10 @@ def on_deploy_failure

private

def debug?(obj)
obj.respond_to?(:verbosity) && obj.verbosity <= SSHKit::Logger::DEBUG
end

def record_new_rake_task
if @tasks[@current_rake_task].nil?
@tasks[@current_rake_task] = []
Expand All @@ -101,14 +107,10 @@ def record_first_execution?(shell_string)
end

def write_log_message(log_message)
return unless log_message.verbosity >= SSHKit::Logger::INFO

print_line(light_black(" " + log_message.to_s))
end

def write_command(command)
return unless command.verbosity > SSHKit::Logger::DEBUG

shell_string = shell_string(command)
if record_first_execution?(shell_string)
print_line " #{number(command)} #{yellow(shell_string)}"
Expand Down

0 comments on commit 59a0296

Please sign in to comment.