Module: Loga::TaggedLogging::Formatter

Included in:
Formatters::GELFFormatter, Formatters::SimpleFormatter
Defined in:
lib/loga/tagged_logging.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#clear_tags!Object



42
43
44
# File 'lib/loga/tagged_logging.rb', line 42

def clear_tags!
  current_tags.clear
end

#current_tagsObject



46
47
48
# File 'lib/loga/tagged_logging.rb', line 46

def current_tags
  Thread.current[:loga_tagged_logging_tags] ||= []
end

#pop_tags(size = 1) ⇒ Object



38
39
40
# File 'lib/loga/tagged_logging.rb', line 38

def pop_tags(size = 1)
  current_tags.pop size
end

#push_tags(*tags) ⇒ Object



32
33
34
35
36
# File 'lib/loga/tagged_logging.rb', line 32

def push_tags(*tags)
  tags.flatten.reject(&:blank?).tap do |new_tags|
    current_tags.concat new_tags
  end
end

#tagged(*tags) ⇒ Object



25
26
27
28
29
30
# File 'lib/loga/tagged_logging.rb', line 25

def tagged(*tags)
  new_tags = push_tags(*tags)
  yield self
ensure
  pop_tags(new_tags.size)
end