Method: Puppet::Util::Logging#debug

Defined in:
lib/puppet/util/logging.rb

#debug(*args) ⇒ Object

Output a debug log message if debugging is on (but only then) If the output is anything except a static string, give the debug a block - it will be called with all other arguments, and is expected to return the single string result.

Use a block at all times for increased performance.

Examples:

This takes 40% of the time compared to not using a block

Puppet.debug { "This is a string that interpolated #{x} and #{y} }"


34
35
36
37
38
39
40
41
42
# File 'lib/puppet/util/logging.rb', line 34

def debug(*args)
  return nil unless Puppet::Util::Log.level == :debug

  if block_given?
    send_log(:debug, yield(*args))
  else
    send_log(:debug, args.join(" "))
  end
end