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.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/chef/chef_class.rb b/lib/chef/chef_class.rb
index c2cb9e2b24..b18c3fbdde 100644
--- a/lib/chef/chef_class.rb
+++ b/lib/chef/chef_class.rb
@@ -204,7 +204,18 @@ class Chef
#
# @api private this will likely be removed in favor of an as-yet unwritten
# `Chef.log`
- def log_deprecation(message, location=caller(2..2)[0])
+ def log_deprecation(message, location=nil)
+ if !location
+ # Pick the first caller that is *not* part of the Chef gem, that's the
+ # thing the user wrote.
+ chef_gem_path = File.expand_path("../..", __FILE__)
+ caller(0..10).each do |c|
+ if !c.start_with?(chef_gem_path)
+ location = c
+ break
+ end
+ end
+ end
# `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`.
if run_context && run_context.events