diff options
author | Thom May <thom@chef.io> | 2017-01-20 13:11:04 +0000 |
---|---|---|
committer | Thom May <thom@chef.io> | 2017-01-20 13:11:04 +0000 |
commit | 33272039bea33e62f8ae25eda047208d4772cf3c (patch) | |
tree | 212d507f4a1feda9f46596fed0b7607700358f14 | |
parent | 60c7fd2a22cc95a8e52e9c0579ed7d49c531635a (diff) | |
download | ohai-33272039bea33e62f8ae25eda047208d4772cf3c.tar.gz |
Only explicitly initialize a logger when neededtm/fix_app_logging
When we're running Ohai as a standalone application, we need to fire up
the logger with our desired location, but when we're run from inside
Chef, we're passed the client's loggers.
Signed-off-by: Thom May <thom@chef.io>
-rw-r--r-- | lib/ohai/application.rb | 2 | ||||
-rw-r--r-- | lib/ohai/system.rb | 4 | ||||
-rw-r--r-- | spec/unit/system_spec.rb | 1 |
3 files changed, 2 insertions, 5 deletions
diff --git a/lib/ohai/application.rb b/lib/ohai/application.rb index 0b0327e7..9f1c400f 100644 --- a/lib/ohai/application.rb +++ b/lib/ohai/application.rb @@ -83,6 +83,8 @@ class Ohai::Application @attributes = nil if @attributes.empty? load_workstation_config + + Ohai::Log.init(Ohai.config[:log_location]) end def run_application diff --git a/lib/ohai/system.rb b/lib/ohai/system.rb index c55383ca..01ee6463 100644 --- a/lib/ohai/system.rb +++ b/lib/ohai/system.rb @@ -220,10 +220,6 @@ module Ohai end def configure_logging - return if Ohai::Log.configured? - - Ohai::Log.init(Ohai.config[:log_location]) - if Ohai.config[:log_level] == :auto Ohai::Log.level = :info else diff --git a/spec/unit/system_spec.rb b/spec/unit/system_spec.rb index 0144ff61..11bec51c 100644 --- a/spec/unit/system_spec.rb +++ b/spec/unit/system_spec.rb @@ -101,7 +101,6 @@ describe "Ohai::System" do it "configures logging" do log_level = :debug Ohai.config[:log_level] = log_level - expect(Ohai::Log).to receive(:init).with(Ohai.config[:log_location]) expect(Ohai::Log).to receive(:level=).with(log_level) Ohai::System.new end |