summaryrefslogtreecommitdiffstats
path: root/lib/puppet/util
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/util')
-rw-r--r--lib/puppet/util/warnings.rb26
1 files changed, 17 insertions, 9 deletions
diff --git a/lib/puppet/util/warnings.rb b/lib/puppet/util/warnings.rb
index 97c96b74c..a63d91359 100644
--- a/lib/puppet/util/warnings.rb
+++ b/lib/puppet/util/warnings.rb
@@ -2,20 +2,28 @@
module Puppet::Util::Warnings
module_function
+ def notice_once(msg)
+ Puppet::Util::Warnings.maybe_log(msg, self.class) { Puppet.notice msg }
+ end
+
+
def warnonce(msg)
- $stampwarnings ||= {}
- $stampwarnings[self.class] ||= []
- unless $stampwarnings[self.class].include? msg
- Puppet.warning msg
- $stampwarnings[self.class] << msg
- end
+ Puppet::Util::Warnings.maybe_log(msg, self.class) { Puppet.warning msg }
+ end
+ def clear_warnings()
+ @stampwarnings = {}
return nil
end
- def clear_warnings()
- $stampwarnings = {}
+ protected
+
+ def self.maybe_log(message, klass)
+ @stampwarnings ||= {}
+ @stampwarnings[klass] ||= []
+ return nil if @stampwarnings[klass].include? message
+ yield
+ @stampwarnings[klass] << message
return nil
end
end
-