Class: Hubbado::Log::Tags
- Inherits:
-
Object
- Object
- Hubbado::Log::Tags
- Defined in:
- lib/hubbado/log/tags.rb
Overview
The operator's list, from LOG_TAGS: an allow-list a message's own tags have to intersect before it is written.
Constant Summary collapse
- ALL =
Every tag is written, whatever else the list says.
:_all- UNTAGGED =
Messages carrying no tag at all are written. Without it, naming any tag silences them.
:_untagged- EVERY_MESSAGE =
A message marks itself as written whatever the operator asked for.
:*- EXCLUSION =
"-".freeze
Instance Attribute Summary collapse
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
Class Method Summary collapse
-
.parse(value) ⇒ Object
Split on commas and nothing else, which is all Eventide's log gem does.
Instance Method Summary collapse
-
#any? ⇒ Boolean
An exclusion-only list still counts as the operator having named tags, which is what makes
-dataon its own silence everything rather than subtract from everything. -
#initialize(tags = []) ⇒ Tags
constructor
A new instance of Tags.
-
#write?(message_tags) ⇒ Boolean
Branch for branch from Eventide's log gem, so that a string an operator writes means the same thing in both codebases.
Constructor Details
#initialize(tags = []) ⇒ Tags
Returns a new instance of Tags.
30 31 32 |
# File 'lib/hubbado/log/tags.rb', line 30 def initialize( = []) @tags = Array().map { |tag| tag.to_s.to_sym } end |
Instance Attribute Details
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
28 29 30 |
# File 'lib/hubbado/log/tags.rb', line 28 def @tags end |
Class Method Details
.parse(value) ⇒ Object
Split on commas and nothing else, which is all Eventide's log gem does. Trimming the spaces would be kinder, and would make one LOG_TAGS mean different things in the two gems that share the variable — the divergence this gem cannot afford.
20 21 22 23 24 25 26 |
# File 'lib/hubbado/log/tags.rb', line 20 def self.parse(value) return value if value.is_a?(self) return new if value.nil? return new(value) if value.is_a?(Array) new(value.to_s.split(",")) end |
Instance Method Details
#any? ⇒ Boolean
An exclusion-only list still counts as the operator having named tags, which is what
makes -data on its own silence everything rather than subtract from everything.
36 37 38 |
# File 'lib/hubbado/log/tags.rb', line 36 def any? !.empty? end |
#write?(message_tags) ⇒ Boolean
Branch for branch from Eventide's log gem, so that a string an operator writes means the
same thing in both codebases. That includes the awkward part: _all is answered before
any exclusion, so _all,-data writes data messages regardless.
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/hubbado/log/tags.rb', line 43 def write?() = Array() return true if .empty? && !any? return true if .include?(EVERY_MESSAGE) return true if named?(ALL) return true if .empty? && named?(UNTAGGED) return true if !.empty? && any? && intersect?() false end |