diff --git a/lib/em-ssh.rb b/lib/em-ssh.rb index 0ed838a..7ede41d 100644 --- a/lib/em-ssh.rb +++ b/lib/em-ssh.rb @@ -49,8 +49,17 @@ def logger(level = Logger::WARN) # log.debug "**** channel: #{channel}" # channel.request_pty(options[:pty] || {}) do |pty,suc| def connect(host, user, opts = {}, &blk) - logger.debug("#{self}.connect(#{host}, #{user}, #{opts})") - options = { :host => host, :user => user, :port => DEFAULT_PORT }.merge(opts) + level = case opts[:verbose] + when :debug then Logger::DEBUG + when :info then Logger::INFO + when :warn then Logger::WARN + when :error then Logger::ERROR + when :fatal then Logger::FATAL + else Logger::WARN + end + @logger = ::Logger.new(STDERR).tap{ |l| l.level = level } + logger(level).debug("#{self}.connect(#{host}, #{user}, #{opts})") + options = { :host => host, :user => user, :port => DEFAULT_PORT, :logger => logger}.merge(opts) EM.connect(options[:host], options[:port], Connection, options, &blk) end alias :start :connect diff --git a/lib/em-ssh/shell.rb b/lib/em-ssh/shell.rb index 0bc9cc1..2a39700 100644 --- a/lib/em-ssh/shell.rb +++ b/lib/em-ssh/shell.rb @@ -68,7 +68,10 @@ def initialize(address, user, pass, opts = {}, &blk) @user = user @pass = pass @options = opts - @connect_opts = {:password => pass, :port => 22, :auth_methods => ['publickey', 'password']}.merge(opts[:net_ssh] || {}) + @port = opts[:port] || 22 + @auth_methods = opts[:auth_methods] || ['publickey', 'password'] + @verbose = opts[:verbose] || :warn + @connect_opts = {:password => pass, :port => @port, :auth_methods => @auth_methods, :verbose => @verbose}.merge(opts[:net_ssh] || {}) @connection = opts[:connection] @parent = opts[:parent] @children = [] @@ -260,7 +263,6 @@ def connect connection.errback do |e| e.set_backtrace(trace + Array(e.backtrace)) fire(:error, e) - f.resume(e) end # err end return Fiber.yield