Class: Vx::Common::TaggedLogging::Formatter
- Inherits:
-
Logger::Formatter
- Object
- Logger::Formatter
- Vx::Common::TaggedLogging::Formatter
- Defined in:
- lib/vx/common/tagged_logging.rb
Constant Summary collapse
- Format =
"[%s] %1s : %s\n"
Instance Method Summary collapse
- #call(severity, time, progname, msg) ⇒ Object
- #clear_tags! ⇒ Object
- #current_tags ⇒ Object
- #pop_tags(size = 1) ⇒ Object
- #push_tags(*tags) ⇒ Object
- #tagged(*tags) ⇒ Object
- #thread_id ⇒ Object
Instance Method Details
#call(severity, time, progname, msg) ⇒ Object
12 13 14 15 16 |
# File 'lib/vx/common/tagged_logging.rb', line 12 def call(severity, time, progname, msg) Format % [format_datetime(time), severity[0...1], msg2str("#{}#{msg}")] end |
#clear_tags! ⇒ Object
39 40 41 |
# File 'lib/vx/common/tagged_logging.rb', line 39 def .clear end |
#current_tags ⇒ Object
43 44 45 |
# File 'lib/vx/common/tagged_logging.rb', line 43 def Thread.current[:activesupport_tagged_logging_tags] ||= [] end |
#pop_tags(size = 1) ⇒ Object
35 36 37 |
# File 'lib/vx/common/tagged_logging.rb', line 35 def (size = 1) .pop size end |
#push_tags(*tags) ⇒ Object
29 30 31 32 33 |
# File 'lib/vx/common/tagged_logging.rb', line 29 def (*) .flatten.reject{|i| i.to_s.strip.empty? }.tap do || .concat end end |
#tagged(*tags) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/vx/common/tagged_logging.rb', line 22 def tagged(*) = (*) yield self ensure (.size) end |
#thread_id ⇒ Object
18 19 20 |
# File 'lib/vx/common/tagged_logging.rb', line 18 def thread_id Thread.current.object_id end |