diff options
Diffstat (limited to 'lib/chef/chef_class.rb')
-rw-r--r-- | lib/chef/chef_class.rb | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/chef/chef_class.rb b/lib/chef/chef_class.rb index 0bb15c03ca..8c766699fc 100644 --- a/lib/chef/chef_class.rb +++ b/lib/chef/chef_class.rb @@ -198,26 +198,35 @@ class Chef # # Emit a deprecation message. # - # @param message The message to send. + # @param type The message to send. This should be a symbol, referring to + # a class defined in Chef::Deprecated + # @param message An explicit message to display, rather than the generic one + # associated with the deprecation. # @param location The location. Defaults to the caller who called you (since # generally the person who triggered the check is the one that needs to be # fixed). # # @example - # Chef.deprecation("Deprecated!") + # Chef.deprecated(:my_deprecation, message: "This is deprecated!") # # @api private this will likely be removed in favor of an as-yet unwritten # `Chef.log` - def log_deprecation(message, location = nil) + def deprecated(type, message, location = nil) location ||= Chef::Log.caller_location + deprecation = Chef::Deprecated.create(type, message, location) # `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 - run_context.events.deprecation(message, location) + run_context.events.deprecation(deprecation, location) else - Chef::Log.deprecation(message, location) + Chef::Log.deprecation(deprecation, location) end end + + def log_deprecation(message, location = nil) + location ||= Chef::Log.caller_location + Chef.deprecated(:generic, message, location) + end end # @api private Only for test dependency injection; not evenly implemented as yet. |