Module: Faraday::DetailedLogger::TaggedLogging::Formatter
- Defined in:
- lib/faraday/detailed_logger/tagged_logging.rb
Constant Summary collapse
- BLANK =
lambda do |value| value.respond_to?(:empty?) ? !!value.empty? : !value end
Instance Method Summary collapse
- #call(severity, timestamp, progname, msg) ⇒ Object
- #clear_tags! ⇒ Object
- #current_tags ⇒ Object
- #pop_tags(size = 1) ⇒ Object
- #push_tags(*tags) ⇒ Object
- #tagged(*tags) ⇒ Object
Instance Method Details
#call(severity, timestamp, progname, msg) ⇒ Object
19 20 21 |
# File 'lib/faraday/detailed_logger/tagged_logging.rb', line 19 def call(severity, , progname, msg) super(severity, , progname, "#{}#{msg}") end |
#clear_tags! ⇒ Object
40 41 42 |
# File 'lib/faraday/detailed_logger/tagged_logging.rb', line 40 def .clear end |
#current_tags ⇒ Object
44 45 46 47 |
# File 'lib/faraday/detailed_logger/tagged_logging.rb', line 44 def @thread_key ||= "faraday_detailed_logger_tags:#{object_id}" Thread.current[@thread_key] ||= [] end |
#pop_tags(size = 1) ⇒ Object
36 37 38 |
# File 'lib/faraday/detailed_logger/tagged_logging.rb', line 36 def (size = 1) .pop size end |
#push_tags(*tags) ⇒ Object
30 31 32 33 34 |
# File 'lib/faraday/detailed_logger/tagged_logging.rb', line 30 def (*) .flatten.reject(&BLANK).tap do || .concat end end |
#tagged(*tags) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/faraday/detailed_logger/tagged_logging.rb', line 23 def tagged(*) = (*) yield self ensure (.size) end |