Class: Steep::TaggedLogging
- Defined in:
- lib/steep/tagged_logging.rb
Overview
A basic implementation of ActiveSupport::TaggedLogging. Might be able to be replaced by plain logger in the future. github.com/ruby/logger/pull/132
Instance Method Summary collapse
- #current_tags ⇒ Object
- #formatted_tags ⇒ Object
-
#initialize ⇒ TaggedLogging
constructor
A new instance of TaggedLogging.
- #push_tags(*tags) ⇒ Object
- #tagged(tag) ⇒ Object
Constructor Details
#initialize ⇒ TaggedLogging
Returns a new instance of TaggedLogging.
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/steep/tagged_logging.rb', line 6 def initialize(...) super self.formatter = proc do |severity, datetime, progname, msg| # @type var severity: String # @type var datetime: Time # @type var progname: untyped # @type var msg: untyped # @type block: String "#{datetime.strftime('%Y-%m-%d %H:%M:%S.%L')}: #{severity}: #{} #{msg}\n" end @thread_key = "steep_tagged_logging_tags:#{object_id}" << "Steep #{VERSION}" end |
Instance Method Details
#current_tags ⇒ Object
27 28 29 |
# File 'lib/steep/tagged_logging.rb', line 27 def Thread.current[@thread_key] ||= [] end |
#formatted_tags ⇒ Object
35 36 37 |
# File 'lib/steep/tagged_logging.rb', line 35 def .map { |tag| "[#{tag}]" }.join(" ") end |
#push_tags(*tags) ⇒ Object
31 32 33 |
# File 'lib/steep/tagged_logging.rb', line 31 def (*) .concat() end |
#tagged(tag) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/steep/tagged_logging.rb', line 20 def tagged(tag) << tag yield ensure .pop end |