Class: SemanticLogger::Formatters::Raw

Inherits:
Object
  • Object
show all
Defined in:
lib/appydays/loggable.rb

Overview

Override SemanticLogger’s keys for tags, named_tags, and payload. It is emminently unhelpful to have three places the same data may be- ie, in some cases, we may have a customer_id in a named tag, sometimes in payload, etc. Callsite behavior should not vary the shape/content of the log message.

Direct Known Subclasses

JsonTrunc

Instance Method Summary collapse

Instance Method Details

#call(log, logger) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/appydays/loggable.rb', line 18

def call(log, logger)
  h = self.original_call(log, logger)
  ctx = h[:context] ||= {}
  ctx[:_tags] = h.delete(:tags) if h.key?(:tags)

  [:named_tags, :payload].each do |hash_key|
    next unless h.key?(hash_key)
    h.delete(hash_key).each do |k, v|
      ctx[k] = v
    end
  end

  return h
end

#original_callObject



16
# File 'lib/appydays/loggable.rb', line 16

alias original_call call