class Chef::Log
Public Class Methods
caller_location()
click to toggle source
Get the location of the caller (from the recipe). Grabs the first caller that is not in the chef gem proper (allowing us to weed out internal calls and give the user a more useful perspective).
@return [String] The location of the caller (file:line#) from caller(0..20), or nil if no non-chef caller is found.
# File lib/chef/log.rb, line 47 def self.caller_location # Pick the first caller that is *not* part of the Chef gem, that's the # thing the user wrote. Or failing that, the most recent caller. chef_gem_path = File.expand_path("../..", __FILE__) caller(0..20).find { |c| !c.start_with?(chef_gem_path) } || caller(0..1)[0] end
deprecation(msg, &block)
click to toggle source
Log
a deprecation warning.
If the treat_deprecation_warnings_as_errors config option is set, this will raise an exception instead.
@param msg [String] Deprecation
message to display.
# File lib/chef/log.rb, line 60 def self.deprecation(msg, &block) if Chef::Config[:treat_deprecation_warnings_as_errors] error(msg, &block) raise Chef::Exceptions::DeprecatedFeatureError.new(msg) else warn(msg, &block) end end