Sha256: 5b81c68f07380302f927ff0b11043df681ec354c904d5bbf0ea3557874fd8ac0

Contents?: true

Size: 750 Bytes

Versions: 20

Compression:

Stored size: 750 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

20 entries across 20 versions & 1 rubygems

Version Path
puppet-8.3.0 lib/puppet/util/warnings.rb
puppet-8.3.0-x86-mingw32 lib/puppet/util/warnings.rb
puppet-8.3.0-x64-mingw32 lib/puppet/util/warnings.rb
puppet-8.3.0-universal-darwin lib/puppet/util/warnings.rb
puppet-8.3.1 lib/puppet/util/warnings.rb
puppet-8.3.1-x86-mingw32 lib/puppet/util/warnings.rb
puppet-8.3.1-x64-mingw32 lib/puppet/util/warnings.rb
puppet-8.3.1-universal-darwin lib/puppet/util/warnings.rb
puppet-8.2.0 lib/puppet/util/warnings.rb
puppet-8.2.0-x86-mingw32 lib/puppet/util/warnings.rb
puppet-8.2.0-x64-mingw32 lib/puppet/util/warnings.rb
puppet-8.2.0-universal-darwin lib/puppet/util/warnings.rb
puppet-8.1.0 lib/puppet/util/warnings.rb
puppet-8.1.0-x86-mingw32 lib/puppet/util/warnings.rb
puppet-8.1.0-x64-mingw32 lib/puppet/util/warnings.rb
puppet-8.1.0-universal-darwin lib/puppet/util/warnings.rb
puppet-8.0.1 lib/puppet/util/warnings.rb
puppet-8.0.1-x86-mingw32 lib/puppet/util/warnings.rb
puppet-8.0.1-x64-mingw32 lib/puppet/util/warnings.rb
puppet-8.0.1-universal-darwin lib/puppet/util/warnings.rb