Skip to content

Commit

Permalink
Add host information to more logging places.
Browse files Browse the repository at this point in the history
Capistrano outputs all logs into a single place which makes it rather difficult
to figure out what has happened on a single host machine, especially when you are
running parallel. By adding host information to the log as possible as it can will
enable tools such as splunk to easily filter out host specific log information, which
is helpful during the later auditing process.
  • Loading branch information
exceedhl committed Nov 24, 2011
1 parent 6134697 commit 4c5967f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/capistrano/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def open_channels

command_line = [environment, shell, cmd].compact.join(" ")
ch[:command] = command_line

logger.trace command_line, ch[:server] if logger
ch.exec(command_line)
ch.send_data(options[:data]) if options[:data]
else
Expand Down
4 changes: 2 additions & 2 deletions lib/capistrano/configuration/actions/invocation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def self.included(base) #:nodoc:

base.default_io_proc = Proc.new do |ch, stream, out|
level = stream == :err ? :important : :info
ch[:options][:logger].send(level, out, "#{stream} :: #{ch[:server]}")
ch[:options][:logger].send(level, out, ch[:server])
end
end

Expand Down Expand Up @@ -231,7 +231,7 @@ def sudo_behavior_callback(fallback) #:nodoc:
if out =~ /^Sorry, try again/
if prompt_host.nil? || prompt_host == ch[:server]
prompt_host = ch[:server]
logger.important out, "#{stream} :: #{ch[:server]}"
logger.important out, ch[:server]
reset! :password
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/capistrano/transfer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def prepare_transfers

def prepare_scp_transfer(from, to, session)
real_callback = callback || Proc.new do |channel, name, sent, total|
logger.trace "[#{channel[:host]}] #{name}" if logger && sent == 0
logger.trace "#{transport} #{operation} #{from} -> #{to}", channel[:host] if logger && sent == 0
end

channel = case direction
Expand Down Expand Up @@ -167,9 +167,9 @@ def prepare_sftp_transfer(from, to, session)
if callback
callback.call(event, op, *args)
elsif event == :open
logger.trace "[#{op[:host]}] #{args[0].remote}"
logger.trace "#{transport} #{operation} #{from} -> #{to}", op[:host]
elsif event == :finish
logger.trace "[#{op[:host]}] done"
logger.trace "#{transport} #{operation} #{from} -> #{to} done", op[:host]
end
end

Expand Down

0 comments on commit 4c5967f

Please sign in to comment.