Module: ActiveSupport::TaggedLogging::Formatter
- Defined in:
- activesupport/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.
22 23 24 |
# File 'activesupport/lib/active_support/tagged_logging.rb', line 22 def call(severity, , progname, msg) super(severity, , progname, "#{}#{msg}") end |
#clear_tags! ⇒ Object
46 47 48 49 |
# File 'activesupport/lib/active_support/tagged_logging.rb', line 46 def @tags_text = nil .clear end |
#current_tags ⇒ Object
51 52 53 54 55 |
# File 'activesupport/lib/active_support/tagged_logging.rb', line 51 def # We use our object ID here to avoid conflicting with other instances thread_key = @thread_key ||= "activesupport_tagged_logging_tags:#{object_id}" Thread.current[thread_key] ||= [] end |
#pop_tags(size = 1) ⇒ Object
41 42 43 44 |
# File 'activesupport/lib/active_support/tagged_logging.rb', line 41 def (size = 1) @tags_text = nil .pop size end |
#push_tags(*tags) ⇒ Object
33 34 35 36 37 38 39 |
# File 'activesupport/lib/active_support/tagged_logging.rb', line 33 def (*) @tags_text = nil .flatten! .reject!(&:blank?) .concat end |
#tagged(*tags) ⇒ Object
26 27 28 29 30 31 |
# File 'activesupport/lib/active_support/tagged_logging.rb', line 26 def tagged(*) = (*) yield self ensure (.size) end |
#tags_text ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# File 'activesupport/lib/active_support/tagged_logging.rb', line 57 def @tags_text ||= begin = if .one? "[#{[0]}] " elsif .any? .collect { |tag| "[#{tag}] " }.join end end end |