Module: ActiveSupport::TaggedLogging::Formatter

Defined in:
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.



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

def call(severity, timestamp, progname, msg)
  super(severity, timestamp, progname, tag_stack.format_message(msg))
end

#clear_tags!Object



51
52
53
# File 'lib/active_support/tagged_logging.rb', line 51

def clear_tags!
  tag_stack.clear
end

#current_tagsObject



61
62
63
# File 'lib/active_support/tagged_logging.rb', line 61

def current_tags
  tag_stack.tags
end

#pop_tags(count = 1) ⇒ Object



47
48
49
# File 'lib/active_support/tagged_logging.rb', line 47

def pop_tags(count = 1)
  tag_stack.pop_tags(count)
end

#push_tags(*tags) ⇒ Object



43
44
45
# File 'lib/active_support/tagged_logging.rb', line 43

def push_tags(*tags)
  tag_stack.push_tags(tags)
end

#tag_stackObject



55
56
57
58
59
# File 'lib/active_support/tagged_logging.rb', line 55

def tag_stack
  # We use our object ID here to avoid conflicting with other instances
  @thread_key ||= "activesupport_tagged_logging_tags:#{object_id}"
  IsolatedExecutionState[@thread_key] ||= TagStack.new
end

#tagged(*tags) ⇒ Object



36
37
38
39
40
41
# File 'lib/active_support/tagged_logging.rb', line 36

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

#tags_textObject



65
66
67
# File 'lib/active_support/tagged_logging.rb', line 65

def tags_text
  tag_stack.format_message("")
end