Module: ActiveSupport::TaggedLogging::Formatter
- Defined in:
- lib/active_support/tagged_logging.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#call(severity, timestamp, progname, msg) ⇒ Object
This method is invoked when a log event occurs.
- #clear_tags! ⇒ Object
- #current_tags ⇒ Object
- #pop_tags(size = 1) ⇒ Object
- #push_tags(*tags) ⇒ Object
- #tagged(*tags) ⇒ Object
- #tags_text ⇒ Object
Instance Method Details
#call(severity, timestamp, progname, msg) ⇒ Object
This method is invoked when a log event occurs.
20 21 22 |
# File 'lib/active_support/tagged_logging.rb', line 20 def call(severity, , progname, msg) super(severity, , progname, "#{}#{msg}") end |
#clear_tags! ⇒ Object
41 42 43 |
# File 'lib/active_support/tagged_logging.rb', line 41 def .clear end |
#current_tags ⇒ Object
45 46 47 48 49 |
# File 'lib/active_support/tagged_logging.rb', line 45 def # We use our object ID here to avoid conflicting with other instances thread_key = @thread_key ||= "activesupport_tagged_logging_tags:#{object_id}".freeze Thread.current[thread_key] ||= [] end |
#pop_tags(size = 1) ⇒ Object
37 38 39 |
# File 'lib/active_support/tagged_logging.rb', line 37 def (size = 1) .pop size end |
#push_tags(*tags) ⇒ Object
31 32 33 34 35 |
# File 'lib/active_support/tagged_logging.rb', line 31 def (*) .flatten.reject(&:blank?).tap do || .concat end end |
#tagged(*tags) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/active_support/tagged_logging.rb', line 24 def tagged(*) = (*) yield self ensure (.size) end |
#tags_text ⇒ Object
51 52 53 54 55 56 |
# File 'lib/active_support/tagged_logging.rb', line 51 def = if .any? .collect { |tag| "[#{tag}] " }.join end end |