class SemanticLogger::Formatters::Raw

def application

Application name
def application
  hash[:application] = logger.application if log_application && logger && logger.application
end

def call(log, logger)

Returns log messages in Hash format
def call(log, logger)
  self.hash   = {}
  self.log    = log
  self.logger = logger
  host
  application
  environment
  time
  level
  pid
  thread_name
  file_name_and_line
  duration
  tags
  named_tags
  name
  message
  payload
  exception
  metric
  hash
end

def duration

Duration
def duration
  return unless log.duration
  hash[:duration_ms] = log.duration
  hash[:duration]    = log.duration_human
end

def environment

Environment
def environment
  hash[:environment] = logger.environment if log_environment && logger && logger.environment
end

def exception

Exception
def exception
  return unless log.exception
  root = hash
  log.each_exception do |exception, i|
    name       = i.zero? ? :exception : :cause
    root[name] = {
      name:        exception.class.name,
      message:     exception.message,
      stack_trace: exception.backtrace
    }
    root = root[name]
  end
end

def file_name_and_line

Ruby file name and line number that logged the message.
def file_name_and_line
  file, line = log.file_name_and_line
  return unless file
  hash[:file] = file
  hash[:line] = line.to_i
end

def host

Host name
def host
  hash[:host] = logger.host if log_host && logger.host
end

def initialize(time_format: :none, time_key: :time, **args)

By default Raw formatter does not reformat the time
def initialize(time_format: :none, time_key: :time, **args)
  @time_key = time_key
  super(time_format: time_format, **args)
end

def level

Log level
def level
  hash[:level]       = log.level
  hash[:level_index] = log.level_index
end

def message

Log message
def message
  hash[:message] = log.cleansed_message if log.message
end

def metric

Metric
def metric
  hash[:metric]        = log.metric if log.metric
  hash[:metric_amount] = log.metric_amount if log.metric_amount
end

def name

Class / app name
def name
  hash[:name] = log.name
end

def named_tags

Named Tags
def named_tags
  hash[:named_tags] = log.named_tags if log.named_tags && !log.named_tags.empty?
end

def payload

Payload
def payload
  hash[:payload] = log.payload if log.payload.respond_to?(:empty?) && !log.payload.empty?
end

def pid

Process ID
def pid
  hash[:pid] = super
end

def tags

Tags
def tags
  hash[:tags] = log.tags if log.tags && !log.tags.empty?
end

def thread_name

Name of the thread that logged the message.
def thread_name
  hash[:thread] = log.thread_name
end

def time

Date & time
def time
  hash[time_key] = format_time(log.time)
end