def log_exception(exception, message = :default, options = {})
    trace = Puppet[:trace] || options[:trace]
    level = options[:level] || :err
    if message == :default && exception.is_a?(Puppet::ParseErrorWithIssue)
      # Retain all detailed info and keep plain message and stacktrace separate
      backtrace = []
      build_exception_trace(backtrace, exception, trace)
      Puppet::Util::Log.create({
          :level => level,
          :source => log_source,
          :message => exception.basic_message,
          :issue_code => exception.issue_code,
          :backtrace => backtrace.empty? ? nil : backtrace,
          :file => exception.file,
          :line => exception.line,
          :pos => exception.pos,
          :environment => exception.environment,
          :node => exception.node
        }.merge(log_metadata))
    else
      send_log(level, format_exception(exception, message, trace))
    end
  end
def log_exception(exception, message = :default, options = {})
    trace = Puppet[:trace] || options[:trace]
    level = options[:level] || :err
    if message == :default && exception.is_a?(Puppet::ParseErrorWithIssue)
      # Retain all detailed info and keep plain message and stacktrace separate
      backtrace = []
      build_exception_trace(backtrace, exception, trace)
      Puppet::Util::Log.create({
          :level => level,
          :source => log_source,
          :message => exception.basic_message,
          :issue_code => exception.issue_code,
          :backtrace => backtrace.empty? ? nil : backtrace,
          :file => exception.file,
          :line => exception.line,
          :pos => exception.pos,
          :environment => exception.environment,
          :node => exception.node
        }.merge(log_metadata))
    else
      send_log(level, format_exception(exception, message, trace))
    end
  end
Log an exception via Puppet.err.  Will also log the backtrace if Puppet[:trace] is set.
 Parameters:
 [exception] an Exception to log
 [message] an optional String overriding the message to be logged; by default, we log Exception.message.
    If you pass a String here, your string will be logged instead.  You may also pass nil if you don't
    wish to log a message at all; in this case it is likely that you are only calling this method in order
    to take advantage of the backtrace logging.