summaryrefslogtreecommitdiff
path: root/lib/chef
diff options
context:
space:
mode:
authorThom May <thom@chef.io>2018-03-22 14:16:25 +0000
committerTim Smith <tsmith@chef.io>2018-03-26 10:31:10 -0700
commit1b81f35e023bcdc87e410c641545e849298de5c3 (patch)
tree67bbbe524d5e465da3748762320f4bf18fba77de /lib/chef
parent5242eef602dd9f00d030a51fbb2bee116b650113 (diff)
downloadchef-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')
-rw-r--r--lib/chef/provider.rb11
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