class Sw::LogFormatter::ContextualFormatter

Attributes

context[RW]
tags[RW]

Public Class Methods

new(context: {}, tags: []) click to toggle source
Calls superclass method
# File lib/sw/log_formatter/contextual_formatter.rb, line 8
def initialize(context: {}, tags: [])
  super()
  self.context = context
  self.tags = tags
end

Public Instance Methods

current_tags() click to toggle source
# File lib/sw/log_formatter/contextual_formatter.rb, line 32
def current_tags
  tags
end
with_context(context) { |self| ... } click to toggle source
# File lib/sw/log_formatter/contextual_formatter.rb, line 14
def with_context(context)
  previous_context = self.context
  self.context = context

  yield self
ensure
  self.context = previous_context
end
with_tags(tags) { |self| ... } click to toggle source
# File lib/sw/log_formatter/contextual_formatter.rb, line 23
def with_tags(tags)
  previous_tags = self.tags
  self.tags = tags

  yield self
ensure
  self.tags = previous_tags
end