diff options
-rw-r--r-- | lib/puppet/functions/deprecation.rb | 8 | ||||
-rw-r--r-- | spec/acceptance/deprecation_spec.rb | 4 |
2 files changed, 8 insertions, 4 deletions
diff --git a/lib/puppet/functions/deprecation.rb b/lib/puppet/functions/deprecation.rb index a860aa2..7082068 100644 --- a/lib/puppet/functions/deprecation.rb +++ b/lib/puppet/functions/deprecation.rb @@ -8,15 +8,19 @@ Puppet::Functions.create_function(:deprecation) do end def deprecation(key, message) + stacktrace = Puppet::Pops::PuppetStack.stacktrace() + file = stacktrace[0] + line = stacktrace[1] + output_message = "#{message} at #{file}:#{line}" # depending on configuration setting of strict case Puppet.settings[:strict] when :off # do nothing when :error - fail("deprecation. #{key}. #{message}") + fail("deprecation. #{key}. #{output_message}") else unless ENV['STDLIB_LOG_DEPRECATIONS'] == 'false' - Puppet.deprecation_warning(message, key) + Puppet.deprecation_warning(output_message, key) end end end diff --git a/spec/acceptance/deprecation_spec.rb b/spec/acceptance/deprecation_spec.rb index ea13700..697c604 100644 --- a/spec/acceptance/deprecation_spec.rb +++ b/spec/acceptance/deprecation_spec.rb @@ -31,7 +31,7 @@ describe 'deprecation function' do end it "should show the error message" do - expect(@result.stderr).to match(/deprecation. key. message/) + expect(@result.stderr).to match(/deprecation. key. message at/) end describe file("#{test_file}") do @@ -53,7 +53,7 @@ describe 'deprecation function' do end it "should show the error message" do - expect(@result.stderr).to match(/Warning: message/) + expect(@result.stderr).to match(/Warning: message at /) end describe file("#{test_file}") do |