summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2018-04-12 13:52:36 -0700
committerGitHub <noreply@github.com>2018-04-12 13:52:36 -0700
commitce3063d31f65060c6b773b88410195e2315a49e5 (patch)
tree3ab7363740ab188264bfe2fc46b2b57d817afe45
parent6ad8977212291ead5e73190e0cb02f8a95060696 (diff)
parent59f51b64894318bbd7d682efb38b0cb985bbefea (diff)
downloadchef-ce3063d31f65060c6b773b88410195e2315a49e5.tar.gz
Merge pull request #7144 from chef/tm/investigate_logging
Fix up knife logging
-rw-r--r--lib/chef/knife.rb8
-rw-r--r--lib/chef/knife/core/bootstrap_context.rb6
-rw-r--r--lib/chef/knife/ssh.rb2
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"