diff options
author | Thom May <thom@chef.io> | 2018-03-22 14:16:25 +0000 |
---|---|---|
committer | Tim Smith <tsmith@chef.io> | 2018-03-26 10:31:10 -0700 |
commit | 1b81f35e023bcdc87e410c641545e849298de5c3 (patch) | |
tree | 67bbbe524d5e465da3748762320f4bf18fba77de /lib/chef/provider.rb | |
parent | 5242eef602dd9f00d030a51fbb2bee116b650113 (diff) | |
download | chef-1b81f35e023bcdc87e410c641545e849298de5c3.tar.gz |
ensure that providers inherit loggers from the run context
Signed-off-by: Thom May <thom@chef.io>
Diffstat (limited to 'lib/chef/provider.rb')
-rw-r--r-- | lib/chef/provider.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/chef/provider.rb b/lib/chef/provider.rb index 6971465b0a..58659c4e95 100644 --- a/lib/chef/provider.rb +++ b/lib/chef/provider.rb @@ -38,6 +38,7 @@ class Chef attr_accessor :run_context attr_reader :recipe_name + attr_reader :logger include Chef::Mixin::WhyRun extend Chef::Mixin::Provides @@ -90,6 +91,12 @@ class Chef @run_context = run_context @converge_actions = nil + @logger = if run_context + run_context.logger.with_child({ resource: new_resource.name, cookbook: cookbook_name, recipe: recipe_name }) + else + Chef::Log.with_child({ resource: new_resource.name, cookbook: cookbook_name, recipe: recipe_name }) + end + @recipe_name = nil @cookbook_name = nil self.class.include_resource_dsl_module(new_resource) @@ -130,7 +137,7 @@ class Chef end def action_nothing - Chef::Log.debug("Doing nothing for #{@new_resource}") + logger.trace("Doing nothing for #{@new_resource}") true end @@ -271,7 +278,7 @@ class Chef end end.join(", ") end - Chef::Log.debug("Skipping update of #{new_resource}: has not changed any of the specified properties #{properties_str}.") + logger.debug("Skipping update of #{new_resource}: has not changed any of the specified properties #{properties_str}.") return false end |