Method: Puppet::Util::Logging#warn_once
- Defined in:
- lib/puppet/util/logging.rb
#warn_once(kind, key, message, file = nil, line = nil, level = :warning) ⇒ Object
Logs a (non deprecation) warning once for a given key.
Either :file and :line and/or :key must be passed.
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/puppet/util/logging.rb', line 181 def warn_once(kind, key, , file = nil, line = nil, level = :warning) return if Puppet[:disable_warnings].include?(kind) $unique_warnings ||= {} if $unique_warnings.length < 100 then unless $unique_warnings.has_key?(key) then $unique_warnings[key] = call_trace = if file == :default and line == :default # Suppress the file and line number output '' else error_location_str = Puppet::Util::Errors.error_location(file, line) if error_location_str.empty? "\n " + _('(file & line not available)') else "\n %{error_location}" % { error_location: error_location_str } end end send_log(level, "#{}#{call_trace}") end end end |