Class: ActiveLogger::Formatters::Base
- Inherits:
-
ActiveSupport::Logger::Formatter
- Object
- ActiveSupport::Logger::Formatter
- ActiveLogger::Formatters::Base
- Defined in:
- lib/active_logger/formatters/base.rb
Overview
:nodoc:
Instance Method Summary collapse
- #call(severity, timestamp, progname, msg) ⇒ Object
- #clear_tags! ⇒ Object
- #current_tags ⇒ Object
- #default_progname ⇒ Object
- #pid ⇒ 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
8 9 10 |
# File 'lib/active_logger/formatters/base.rb', line 8 def call(severity, , progname, msg) super(severity, , progname, msg) end |
#clear_tags! ⇒ Object
32 33 34 35 |
# File 'lib/active_logger/formatters/base.rb', line 32 def @tags_text = nil .clear end |
#current_tags ⇒ Object
37 38 39 40 41 |
# File 'lib/active_logger/formatters/base.rb', line 37 def # We use our object ID here to avoid conflicting with other instances thread_key = @thread_key ||= "activelogger_tagged_logging_tags:#{object_id}" Thread.current[thread_key] ||= [] end |
#default_progname ⇒ Object
58 59 60 |
# File 'lib/active_logger/formatters/base.rb', line 58 def default_progname $PROGRAM_NAME end |
#pid ⇒ Object
54 55 56 |
# File 'lib/active_logger/formatters/base.rb', line 54 def pid $PID end |
#pop_tags(size = 1) ⇒ Object
27 28 29 30 |
# File 'lib/active_logger/formatters/base.rb', line 27 def (size = 1) @tags_text = nil .pop size end |
#push_tags(*tags) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/active_logger/formatters/base.rb', line 19 def (*) @tags_text = nil .flatten! .reject!(&:blank?) .concat end |
#tagged(*tags) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/active_logger/formatters/base.rb', line 12 def tagged(*) = (*) yield self ensure (.size) end |
#tags_text ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/active_logger/formatters/base.rb', line 43 def @tags_text ||= begin = if .one? "[#{[0]}] " elsif .any? .collect { |tag| "[#{tag}] " }.join end end end |