summaryrefslogtreecommitdiff
path: root/lib/chef/chef_class.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/chef_class.rb')
-rw-r--r--lib/chef/chef_class.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/chef/chef_class.rb b/lib/chef/chef_class.rb
index 458ac82467..e825bedb34 100644
--- a/lib/chef/chef_class.rb
+++ b/lib/chef/chef_class.rb
@@ -190,6 +190,22 @@ class Chef
def resource_handler_map
@resource_handler_map ||= Chef::Platform::ResourceHandlerMap.instance
end
+
+ #
+ # @overload log
+ # Get the current log object.
+ #
+ # @return An object that supports `deprecation(message)`
+ #
+ # @example
+ # run_context.log.deprecation("Deprecated!")
+ #
+ # @api private
+ def log
+ # `run_context.events` is the primary deprecation target if we're in a run. If we
+ # are not yet in a run, print to `Chef::Log`.
+ (run_context && run_context.events) || Chef::Log
+ end
end
reset!