class Lumberjack::Context
A context is used to store tags that are then added to all log entries within a block.
Attributes
Public Class Methods
new(parent_context = nil)
click to toggle source
# File lib/lumberjack/context.rb, line 8 def initialize(parent_context = nil) @tags = {} @tags.merge!(parent_context.tags) if parent_context end
Public Instance Methods
[](key)
click to toggle source
Get a context tag.
# File lib/lumberjack/context.rb, line 21 def [](key) @tags[key.to_s] end
[]=(key, value)
click to toggle source
Set a context tag.
# File lib/lumberjack/context.rb, line 26 def []=(key, value) @tags[key.to_s] = value end
reset()
click to toggle source
Clear all the context data.
# File lib/lumberjack/context.rb, line 31 def reset @tags.clear end
tag(tags)
click to toggle source
Set tags on the context.
# File lib/lumberjack/context.rb, line 14 def tag(tags) tags.each do |key, value| @tags[key.to_s] = value end end