diff options
| author | Markus Roberts <Markus@reality.com> | 2010-10-22 07:09:30 -0700 |
|---|---|---|
| committer | Nick Lewis <nick@puppetlabs.com> | 2011-04-12 12:47:31 -0700 |
| commit | e5609ffefb4132049a969d88f74138058fe78694 (patch) | |
| tree | 8c04fc6413b350214935eeb54a94a9265100c1e2 /lib | |
| parent | 1954bbfe175ae7f18316e57af43362eb4ed73553 (diff) | |
| download | puppet-e5609ffefb4132049a969d88f74138058fe78694.tar.gz puppet-e5609ffefb4132049a969d88f74138058fe78694.tar.xz puppet-e5609ffefb4132049a969d88f74138058fe78694.zip | |
Step towards #5027 -- add Logging#deprication_warning facility
This commit adds a method analogous to Puppet.warn which 1) only logs each
message the first time it is received and 2) only logs the first 100 messages
it receives. Messages are logged via warn.
This could easily be made more flexible by making the hard limit and effective
log level user settable, if desired.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/puppet/util/logging.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/puppet/util/logging.rb b/lib/puppet/util/logging.rb index bc52b17f0..b6845b8fa 100644 --- a/lib/puppet/util/logging.rb +++ b/lib/puppet/util/logging.rb @@ -15,6 +15,17 @@ module Puppet::Util::Logging end end + def deprication_warning(message) + $deprication_warnings ||= Hash.new(0) + if $deprication_warnings.length < 100 and ($deprication_warnings[message] += 1) == 1 + warn message + end + end + + def clear_deprication_warnings + $deprication_warnings.clear if $deprication_warnings + end + private def is_resource? |
