diff options
author | Jamis Buck <jamis@37signals.com> | 2008-04-25 21:54:16 -0600 |
---|---|---|
committer | Jamis Buck <jamis@37signals.com> | 2008-04-25 21:54:16 -0600 |
commit | d59b647b8ea08bc02f6dc8ac6f550c1849f369aa (patch) | |
tree | ef52c7f8ca337a0c6eec75a95c701204c9a4308e | |
parent | 785b0cc0005fe989bef1b21291bffbad6a7ce8a4 (diff) | |
download | net-ssh-d59b647b8ea08bc02f6dc8ac6f550c1849f369aa.tar.gz |
Allow the :verbose argument to accept symbols (:debug, etc.) as well as Logger level constants (Logger::DEBUG, etc.)
-rw-r--r-- | CHANGELOG.rdoc | 5 | ||||
-rw-r--r-- | lib/net/ssh.rb | 15 |
2 files changed, 18 insertions, 2 deletions
diff --git a/CHANGELOG.rdoc b/CHANGELOG.rdoc index 62f9a94..5c2c89f 100644 --- a/CHANGELOG.rdoc +++ b/CHANGELOG.rdoc @@ -1,3 +1,8 @@ +=== *unreleased* + +* Allow the :verbose argument to accept symbols (:debug, etc.) as well as Logger level constants (Logger::DEBUG, etc.) [Jamis Buck] + + === 2.0 Preview Release 4 (1.99.3) / 19 Apr 2008 * Make sure HOME is set to something sane, even on OS's that don't set it by default [Jamis Buck] diff --git a/lib/net/ssh.rb b/lib/net/ssh.rb index 0187213..00a878e 100644 --- a/lib/net/ssh.rb +++ b/lib/net/ssh.rb @@ -145,7 +145,8 @@ module Net # Defaults to %w(~/.ssh/known_hosts ~/.ssh/known_hosts2). # * :verbose => how verbose to be (Logger verbosity constants, Logger::DEBUG # is very verbose, Logger::FATAL is all but silent). Logger::FATAL is the - # default. + # default. The symbols :debug, :info, :warn, :error, and :fatal are also + # supported and are translated to the corresponding Logger constant. def self.start(host, user, options={}, &block) invalid_options = options.keys - VALID_OPTIONS if invalid_options.any? @@ -166,7 +167,17 @@ module Net options[:logger].level = Logger::FATAL end - options[:logger].level = options[:verbose] if options[:verbose] + if options[:verbose] + options[:logger].level = case options[:verbose] + when Fixnum then options[: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 raise ArgumentError, "can't convert #{options[:verbose].inspect} to any of the Logger level constants" + end + end transport = Transport::Session.new(host, options) auth = Authentication::Session.new(transport, options) |