module ActiveSupport::TaggedLogging::Formatter

def call(severity, timestamp, progname, msg)

This method is invoked when a log event occurs.
:nodoc:
def call(severity, timestamp, progname, msg)
  super(severity, timestamp, progname, "#{tags_text}#{msg}")
end

def clear_tags!

def clear_tags!
  current_tags.clear
end

def current_tags

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

def pop_tags(size = 1)

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

def push_tags(*tags)

def push_tags(*tags)
  tags.flatten!
  tags.reject!(&:blank?)
  current_tags.concat tags
  tags
end

def tagged(*tags)

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

def tags_text

def tags_text
  tags = current_tags
  if tags.one?
    "[#{tags[0]}] "
  elsif tags.any?
    tags.collect { |tag| "[#{tag}] " }.join
  end
end