Module: Lumberjack::TaggedLoggerSupport
- Defined in:
- lib/lumberjack/tagged_logger_support.rb
Overview
Methods to make Lumberjack::Logger API compatible with ActiveSupport::TaggedLogger.
Defined Under Namespace
Classes: Formatter
Instance Method Summary collapse
- #clear_tags! ⇒ Object
- #pop_tags(size = 1) ⇒ Object
- #push_tags(*tags) ⇒ Object
-
#tagged(*tags, &block) ⇒ Object
Compatibility with ActiveSupport::TaggedLogging which only supports adding tags as strings.
Instance Method Details
#clear_tags! ⇒ Object
62 63 64 |
# File 'lib/lumberjack/tagged_logger_support.rb', line 62 def tag("tagged" => nil) end |
#pop_tags(size = 1) ⇒ Object
56 57 58 59 60 |
# File 'lib/lumberjack/tagged_logger_support.rb', line 56 def (size = 1) tagged_values = Array(@tags["tagged"]) tagged_values = ((tagged_values.size > size) ? tagged_values[0, tagged_values.size - size] : nil) tag("tagged" => tagged_values) end |
#push_tags(*tags) ⇒ Object
52 53 54 |
# File 'lib/lumberjack/tagged_logger_support.rb', line 52 def (*) tagged(*) end |
#tagged(*tags, &block) ⇒ Object
Compatibility with ActiveSupport::TaggedLogging which only supports adding tags as strings. If a tag looks like “key:value” or “key=value”, it will be added as a key value pair. Otherwise it will be appended to a list named “tagged”.
43 44 45 46 47 48 49 50 |
# File 'lib/lumberjack/tagged_logger_support.rb', line 43 def tagged(*, &block) tag_hash = {} .flatten.each do |tag| tagged_values = Array(tag_hash["tagged"] || self.["tagged"]) tag_hash["tagged"] = tagged_values + [tag] end tag(tag_hash, &block) end |