Skip to content

Commit

Permalink
Improve logging output
Browse files Browse the repository at this point in the history
Before: Notice: Puppet::ResourceApi::PuppetContext::PuppetLogger: title_provider[foo]: Creating: Creating 'foo' with {:namevar=>"foo", :ensure=>:present, :ip=>"127.0.1.1"}

After: Notice: title_provider[foo]: Creating: Creating 'foo' with {:namevar=>"foo", :ensure=>:present, :ip=>"127.0.1.1"}
  • Loading branch information
DavidS committed Mar 23, 2018
1 parent e769188 commit 95b038f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
7 changes: 1 addition & 6 deletions lib/puppet/resource_api/puppet_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@
require 'puppet/util/logging'

class Puppet::ResourceApi::PuppetContext < Puppet::ResourceApi::BaseContext
# declare a separate class to encapsulate Puppet's logging facilities
class PuppetLogger
extend Puppet::Util::Logging
end

protected

def send_log(level, message)
PuppetLogger.send_log(level, message)
Puppet::Util::Log.create(level: level, message: message)
end
end
2 changes: 1 addition & 1 deletion spec/puppet/resource_api/puppet_context_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

describe '#warning(msg)' do
it 'calls the Puppet logging infrastructure' do
expect(Puppet::ResourceApi::PuppetContext::PuppetLogger).to receive(:send_log).with(:warning, match(%r{message}))
expect(Puppet::Util::Log).to receive(:create).with(level: :warning, message: match(%r{message}))
context.warning('message')
end
end
Expand Down

0 comments on commit 95b038f

Please sign in to comment.