Method: Timber::CurrentContext#add

Defined in:
lib/timber/current_context.rb

#add(*contexts) ⇒ Object

Note:

Because context is included with every log line, it is recommended that you limit this to only neccessary data.

Adds contexts but does not remove them. See #with for automatic maintenance and #remove to remove them yourself.



70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/timber/current_context.rb', line 70

def add(*contexts)
  contexts.each do |context|
    key = context.keyspace
    json = context.as_json # Convert to json now so that we aren't doing it for every line
    if key == :custom
      # Custom contexts are merged into the space
      hash[key] ||= {}
      hash[key].merge(json)
    else
      hash[key] = json
    end
  end
end