summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2015-05-15 10:52:17 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2015-05-15 10:52:17 -0700
commitd3b0f2ce30e4a8cbcbdd0c7128f4ae710a189e83 (patch)
treea4c129fb401e234bd767602ff9d097235ce7059a
parentb086721ca70750277c407fd0cc573a08f076649f (diff)
downloadchef-d3b0f2ce30e4a8cbcbdd0c7128f4ae710a189e83.tar.gz
change default log_location + log_level for knife
send logging to STDERR and drop default log_level to :warn so that we can see warnings again. logging needs to go to STDERR so that we don't break someone's 'API' where they're piping stdin to some filter. we believe the log_level was not warn in order to suppress warns off of 404s which no longer warn by default now.
-rw-r--r--lib/chef/knife.rb4
-rw-r--r--spec/unit/knife_spec.rb12
2 files changed, 15 insertions, 1 deletions
diff --git a/lib/chef/knife.rb b/lib/chef/knife.rb
index 4c59f831de..71215e7fbf 100644
--- a/lib/chef/knife.rb
+++ b/lib/chef/knife.rb
@@ -359,7 +359,7 @@ class Chef
case Chef::Config[:verbosity]
when 0, nil
- Chef::Config[:log_level] = :error
+ Chef::Config[:log_level] = :warn
when 1
Chef::Config[:log_level] = :info
else
@@ -401,6 +401,8 @@ class Chef
end
def configure_chef
+ # knife needs to send logger output to STDERR by default
+ Chef::Config[:log_location] = STDERR
config_loader = self.class.load_config(config[:config_file])
config[:config_file] = config_loader.config_location
diff --git a/spec/unit/knife_spec.rb b/spec/unit/knife_spec.rb
index 7cb16aae2a..7aab16ce99 100644
--- a/spec/unit/knife_spec.rb
+++ b/spec/unit/knife_spec.rb
@@ -252,6 +252,18 @@ describe Chef::Knife do
:default => "default-value")
end
+ it "sets the default log_location to STDERR for Chef::Log warnings" do
+ knife_command = KnifeSpecs::TestYourself.new([])
+ knife_command.configure_chef
+ expect(Chef::Config[:log_location]).to eq(STDERR)
+ end
+
+ it "sets the default log_level to warn so we can issue Chef::Log.warn" do
+ knife_command = KnifeSpecs::TestYourself.new([])
+ knife_command.configure_chef
+ expect(Chef::Config[:log_level]).to eql(:warn)
+ end
+
it "prefers the default value if no config or command line value is present" do
knife_command = KnifeSpecs::TestYourself.new([]) #empty argv
knife_command.configure_chef