lib/ztk/ssh.rb in ztk-0.1.0 vs lib/ztk/ssh.rb in ztk-0.1.1
- old
+ new
@@ -107,10 +107,16 @@
:compression => false,
:user_known_hosts_file => '/dev/null'
}.merge(config))
end
+ def inspect
+ user_host = "#{@config.user}@#{@config.host_name}"
+ port = (@config.port ? ":#{@config.port}" : nil)
+ [user_host, port].compact.join
+ end
+
# Starts an SSH session. Can also be used to get the Net::SSH object.
#
# Primarily used internally.
def ssh
@ssh ||= Net::SSH.start(@config.host_name, @config.user, ssh_options)
@@ -180,16 +186,16 @@
log(:debug) { "channel opened" }
chan.exec(command) do |ch, success|
raise SSHError, "Could not execute '#{command}'." unless success
ch.on_data do |c, data|
- log(:debug) { data.chomp.strip }
+ direct_log(:debug) { "[#{self.inspect}] #{data}" }
@config.stdout.print(data) unless options.silence
output += data.chomp.strip
end
ch.on_extended_data do |c, type, data|
- log(:debug) { data.chomp.strip }
+ direct_log(:debug) { "[#{self.inspect}] #{data}" }
@config.stderr.print(data) unless options.silence
output += data.chomp.strip
end
end