Method: Puppet::Util::Logging#log_deprecations_to_file
- Defined in:
- lib/puppet/util/logging.rb
#log_deprecations_to_file(deprecations_file, pattern = nil) ⇒ Object
utility method that can be called, e.g., from spec_helper config.after, when tracking down calls to deprecated code. Parameters:
- deprecations_file
-
relative or absolute path of a file to log the deprecations to
- pattern
-
(default nil) if specified, will only log deprecations whose message matches the provided pattern
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
# File 'lib/puppet/util/logging.rb', line 230 def log_deprecations_to_file(deprecations_file, pattern = nil) # this method may get called lots and lots of times (e.g., from spec_helper config.after) without the global # list of deprecation warnings being cleared out. We don't want to keep logging the same offenders over and over, # so, we need to keep track of what we've logged. # # It'd be nice if we could just clear out the list of deprecation warnings, but then the very next spec might # find the same offender, and we'd end up logging it again. $logged_deprecation_warnings ||= {} # Deprecation messages are UTF-8 as they are produced by Ruby Puppet::FileSystem.open(deprecations_file, nil, "a:UTF-8") do |f| if $deprecation_warnings then $deprecation_warnings.each do |offender, | next if $logged_deprecation_warnings.has_key?(offender) $logged_deprecation_warnings[offender] = true next unless pattern.nil? || ( =~ pattern) f.puts() f.puts(offender) f.puts() end end end end |