Class: NRSER::Log::Formatters::Mixin::Tokens
- Defined in:
- lib/nrser/log/formatters/mixin.rb
Overview
Abstract base class for HeaderTokens and BodyTokens, instances of which are used by formatters that include NRSER::Log::Formatters::Mixin to configure what pieces of information make up the header and body sections of log messages that it formats.
Entries are SemanticLogger::Formatter::Default method names, which I’ve called “tokens”, and the order of the “tokens” dictates the order the results of those method calls will be joined to form the formatted message section.
Adding, removing and reordering tokens is used to control what elements appear and where in the formatted result.
Token arrays are mutable and meant to changed in place via Array#delete and friends.
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(tokens = self.class::ALL) ⇒ Tokens
constructor
Create a new token array.
-
#reset! ⇒ Tokens
Reset the array to be all the available tokens for the section in their original order.
Methods inherited from Array
#ellipsis, #extract!, #rest, #to_chainer, #to_digger, #to_message, #to_pair, #to_proc, #to_sender
Methods included from Ext::Tree
#each_branch, #leaves, #map_branches, #map_leaves, #map_tree
Constructor Details
#initialize(tokens = self.class::ALL) ⇒ Tokens
Create a new token array.
65 66 67 |
# File 'lib/nrser/log/formatters/mixin.rb', line 65 def initialize tokens = self.class::ALL super tokens.map( &:to_sym ) end |
Instance Method Details
#reset! ⇒ Tokens
Reset the array to be all the available tokens for the section in their original order.
**Mutates the array in place.**
78 79 80 81 82 |
# File 'lib/nrser/log/formatters/mixin.rb', line 78 def reset! clear self.class::ALL.each { |token| self << token } self end |