Module: ActiveSupport::TaggedLogging::Formatter

Defined in:
activesupport/lib/active_support/tagged_logging.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#call(severity, timestamp, progname, msg) ⇒ Object

This method is invoked when a log event occurs.


20
21
22
# File 'activesupport/lib/active_support/tagged_logging.rb', line 20

def call(severity, timestamp, progname, msg)
  super(severity, timestamp, progname, "#{tags_text}#{msg}")
end

#clear_tags!Object


41
42
43
# File 'activesupport/lib/active_support/tagged_logging.rb', line 41

def clear_tags!
  current_tags.clear
end

#current_tagsObject


45
46
47
# File 'activesupport/lib/active_support/tagged_logging.rb', line 45

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

#pop_tags(size = 1) ⇒ Object


37
38
39
# File 'activesupport/lib/active_support/tagged_logging.rb', line 37

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

#push_tags(*tags) ⇒ Object


31
32
33
34
35
# File 'activesupport/lib/active_support/tagged_logging.rb', line 31

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

#tagged(*tags) ⇒ Object


24
25
26
27
28
29
# File 'activesupport/lib/active_support/tagged_logging.rb', line 24

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