diff options
author | Thom May <thom@chef.io> | 2018-04-11 13:27:05 +0100 |
---|---|---|
committer | Thom May <thom@chef.io> | 2018-04-11 13:27:05 +0100 |
commit | 59f51b64894318bbd7d682efb38b0cb985bbefea (patch) | |
tree | a8dd514d6915d5ede389d3c3bcfa80093f2ae83e | |
parent | 76fa86f06fc4b4ed2c4ba165c64b28538c6d637c (diff) | |
download | chef-59f51b64894318bbd7d682efb38b0cb985bbefea.tar.gz |
Fix up knife loggingtm/investigate_logging
ensure that trace level is selectable if necessary via -VVV
Pass the correct object to net/ssh
Signed-off-by: Thom May <thom@chef.io>
-rw-r--r-- | lib/chef/knife.rb | 8 | ||||
-rw-r--r-- | lib/chef/knife/core/bootstrap_context.rb | 6 | ||||
-rw-r--r-- | lib/chef/knife/ssh.rb | 2 |
3 files changed, 11 insertions, 5 deletions
diff --git a/lib/chef/knife.rb b/lib/chef/knife.rb index 4e975c2b27..1e436f0fe6 100644 --- a/lib/chef/knife.rb +++ b/lib/chef/knife.rb @@ -370,11 +370,13 @@ class Chef Chef::Config[:log_level] = :warn when 1 Chef::Config[:log_level] = :info - else + when 2 Chef::Config[:log_level] = :debug + else + Chef::Config[:log_level] = :trace end - Chef::Config[:log_level] = :debug if ENV["KNIFE_DEBUG"] + Chef::Config[:log_level] = :trace if ENV["KNIFE_DEBUG"] Chef::Config[:node_name] = config[:node_name] if config[:node_name] Chef::Config[:client_key] = config[:client_key] if config[:client_key] @@ -467,7 +469,7 @@ class Chef when NameError, NoMethodError ui.error "knife encountered an unexpected error" ui.info "This may be a bug in the '#{self.class.common_name}' knife command or plugin" - ui.info "Please collect the output of this command with the `-VV` option before filing a bug report." + ui.info "Please collect the output of this command with the `-VVV` option before filing a bug report." ui.info "Exception: #{e.class.name}: #{e.message}" when Chef::Exceptions::PrivateKeyMissing ui.error "Your private key could not be loaded from #{api_key}" diff --git a/lib/chef/knife/core/bootstrap_context.rb b/lib/chef/knife/core/bootstrap_context.rb index adbdee1858..deb7f8a3b4 100644 --- a/lib/chef/knife/core/bootstrap_context.rb +++ b/lib/chef/knife/core/bootstrap_context.rb @@ -178,7 +178,11 @@ validation_client_name "#{@chef_config[:validation_client_name]}" # If the user doesn't have a client path configure, let bash use the PATH for what it was designed for client_path = @chef_config[:chef_client_path] || "chef-client" s = "#{client_path} -j /etc/chef/first-boot.json" - s << " -l debug" if @config[:verbosity] && @config[:verbosity] >= 2 + if @config[:verbosity] && @config[:verbosity] >= 3 + s << " -l trace" + elsif @config[:verbosity] && @config[:verbosity] >= 2 + s << " -l debug" + end s << " -E #{bootstrap_environment}" unless bootstrap_environment.nil? s << " --no-color" unless @config[:color] s diff --git a/lib/chef/knife/ssh.rb b/lib/chef/knife/ssh.rb index c0df6ecae8..c38dc43e74 100644 --- a/lib/chef/knife/ssh.rb +++ b/lib/chef/knife/ssh.rb @@ -288,7 +288,7 @@ class Chef opts[:forward_agent] = forward_agent unless forward_agent.nil? port ||= ssh_config[:port] opts[:port] = port unless port.nil? - opts[:logger] = Chef::Log.logger if Chef::Log.level == :debug + opts[:logger] = Chef::Log.with_child(subsystem: "net/ssh") if Chef::Log.level == :trace if !config[:host_key_verify] opts[:verify_host_key] = false opts[:user_known_hosts_file] = "/dev/null" |