class NRSER::Log::Formatters::Mixin::Tokens

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.

Public Class Methods

new(tokens = self.class::ALL) click to toggle source

Create a new token array.

@param [Array<#to_sym>] tokens

The token symbols to initialize the array with. Must be covetable
to symbols (really, just pass symbols in the first place).
Calls superclass method
# File lib/nrser/log/formatters/mixin.rb, line 65
def initialize tokens = self.class::ALL
  super tokens.map( &:to_sym )
end

Public Instance Methods

reset!() click to toggle source

Reset the array to be all the available tokens for the section in their original order.

**Mutates the array in place.**

@return [Tokens]

`self`.
# File lib/nrser/log/formatters/mixin.rb, line 78
def reset!
  clear
  self.class::ALL.each { |token| self << token }
  self
end