Sha256: f74cd2be8ebf0b3c933c9468c48502075cb751db6f750a02e198aa8af121c514

Contents?: true

Size: 753 Bytes

Versions: 32

Compression:

Stored size: 753 Bytes

Contents

# frozen_string_literal: true

# Methods to help with handling warnings.
module Puppet::Util::Warnings
  module_function

  def notice_once(msg)
    Puppet::Util::Warnings.maybe_log(msg, self.class) { Puppet.notice msg }
  end

  def debug_once(msg)
    return nil unless Puppet[:debug]

    Puppet::Util::Warnings.maybe_log(msg, self.class) { Puppet.debug msg }
  end

  def warnonce(msg)
    Puppet::Util::Warnings.maybe_log(msg, self.class) { Puppet.warning msg }
  end

  def clear_warnings
    @stampwarnings = {}
    nil
  end

  def self.maybe_log(message, klass)
    @stampwarnings ||= {}
    @stampwarnings[klass] ||= []
    return nil if @stampwarnings[klass].include? message

    yield
    @stampwarnings[klass] << message
    nil
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
puppet-8.10.0 lib/puppet/util/warnings.rb
puppet-8.10.0-x86-mingw32 lib/puppet/util/warnings.rb
puppet-8.10.0-x64-mingw32 lib/puppet/util/warnings.rb
puppet-8.10.0-universal-darwin lib/puppet/util/warnings.rb
puppet-8.9.0 lib/puppet/util/warnings.rb
puppet-8.9.0-x86-mingw32 lib/puppet/util/warnings.rb
puppet-8.9.0-x64-mingw32 lib/puppet/util/warnings.rb
puppet-8.9.0-universal-darwin lib/puppet/util/warnings.rb
puppet-8.8.1 lib/puppet/util/warnings.rb
puppet-8.8.1-x86-mingw32 lib/puppet/util/warnings.rb
puppet-8.8.1-x64-mingw32 lib/puppet/util/warnings.rb
puppet-8.8.1-universal-darwin lib/puppet/util/warnings.rb
puppet-8.7.0 lib/puppet/util/warnings.rb
puppet-8.7.0-x86-mingw32 lib/puppet/util/warnings.rb
puppet-8.7.0-x64-mingw32 lib/puppet/util/warnings.rb
puppet-8.7.0-universal-darwin lib/puppet/util/warnings.rb
puppet-8.6.0 lib/puppet/util/warnings.rb
puppet-8.6.0-x86-mingw32 lib/puppet/util/warnings.rb
puppet-8.6.0-x64-mingw32 lib/puppet/util/warnings.rb
puppet-8.6.0-universal-darwin lib/puppet/util/warnings.rb