From 33272039bea33e62f8ae25eda047208d4772cf3c Mon Sep 17 00:00:00 2001 From: Thom May Date: Fri, 20 Jan 2017 13:11:04 +0000 Subject: Only explicitly initialize a logger when needed 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 --- lib/ohai/application.rb | 2 ++ lib/ohai/system.rb | 4 ---- 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 -- cgit v1.2.1