Skip to content

Commit

Permalink
Only explicitly initialize a logger when needed
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Thom May committed Jan 20, 2017
1 parent 60c7fd2 commit 3327203
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 5 deletions.
2 changes: 2 additions & 0 deletions lib/ohai/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ def configure_ohai
@attributes = nil if @attributes.empty?

load_workstation_config

Ohai::Log.init(Ohai.config[:log_location])
end

def run_application
Expand Down
4 changes: 0 additions & 4 deletions lib/ohai/system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,6 @@ def configure_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
Expand Down
1 change: 0 additions & 1 deletion spec/unit/system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@
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
Expand Down

0 comments on commit 3327203

Please sign in to comment.