class Semlogr::Formatters::PropertyValueFormatter

Constants

NEW_LINE
NO_VALUE

Public Class Methods

format(value) click to toggle source
# File lib/semlogr/formatters/property_value_formatter.rb, line 9
def self.format(value)
  case value
  when nil
    NO_VALUE
  when String
    "\"#{value}\""
  when StandardError
    formatted_error = +"#{value.class}: #{value.message}"

    if value.backtrace&.any?
      formatted_error << "\n\s\s#{value.backtrace.join("\n\s\s")}"
    end

    formatted_error << NEW_LINE
  else
    value.to_s
  end
end