Skip to content

Commit 64abfc9

Browse files
author
Helen Campbell
committed
Call site display for deprecation warnings
1 parent dcef77a commit 64abfc9

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

lib/puppet/functions/deprecation.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,19 @@
88
end
99

1010
def deprecation(key, message)
11+
stacktrace = Puppet::Pops::PuppetStack.stacktrace()
12+
file = stacktrace[0]
13+
line = stacktrace[1]
14+
output_message = "#{message} at #{file}:#{line}"
1115
# depending on configuration setting of strict
1216
case Puppet.settings[:strict]
1317
when :off
1418
# do nothing
1519
when :error
16-
fail("deprecation. #{key}. #{message}")
20+
fail("deprecation. #{key}. #{output_message}")
1721
else
1822
unless ENV['STDLIB_LOG_DEPRECATIONS'] == 'false'
19-
Puppet.deprecation_warning(message, key)
23+
Puppet.deprecation_warning(output_message, key)
2024
end
2125
end
2226
end

spec/acceptance/deprecation_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
end
3232

3333
it "should show the error message" do
34-
expect(@result.stderr).to match(/deprecation. key. message/)
34+
expect(@result.stderr).to match(/deprecation. key. message at/)
3535
end
3636

3737
describe file("#{test_file}") do
@@ -53,7 +53,7 @@
5353
end
5454

5555
it "should show the error message" do
56-
expect(@result.stderr).to match(/Warning: message/)
56+
expect(@result.stderr).to match(/Warning: message at /)
5757
end
5858

5959
describe file("#{test_file}") do

0 commit comments

Comments
 (0)