1 # Function to print deprecation warnings, Logs a warning once for a given key.
3 # The uniqueness key - can appear once.
4 # The msg is the message text including any positional information that is formatted by the
5 # user/caller of the method.
6 # It is affected by the puppet setting 'strict', which can be set to :error
7 # (outputs as an error message), :off (no message / error is displayed) and :warning
8 # (default, outputs a warning) *Type*: String, String.
10 Puppet::Functions.create_function(:deprecation) do
13 # @return deprecated warnings
14 dispatch :deprecation do
16 param 'String', :message
19 def deprecation(key, message)
20 if defined? Puppet::Pops::PuppetStack.stacktrace
21 stacktrace = Puppet::Pops::PuppetStack.stacktrace()
24 message = "#{message} at #{file}:#{line}"
26 # depending on configuration setting of strict
27 case Puppet.settings[:strict]
28 when :off # rubocop:disable Lint/EmptyWhen : Is required to prevent false errors
31 raise("deprecation. #{key}. #{message}")
33 unless ENV['STDLIB_LOG_DEPRECATIONS'] == 'false'
34 Puppet.deprecation_warning(message, key)