Documentation ¶
Overview ¶
Package processor provides the building blocks to create processors, which are used to process messages before they are printed. It also provides a collection of built-in processors.
NOTES: - Processors are executed in the order they are added to the pipeline. - It's the implementator's responsibility to check if the message has content. Sypl doesn't touch the message's content - it pass thru as it's, raw - as any logger. Only processors are able to change the message's content. Use the `IsEmpty` help method to check if the message has content.
Index ¶
- func NewProcessingError(m message.IMessage, e error) error
- type Casing
- type IProcessor
- func ChangeFirstCharCase(casing Casing) IProcessor
- func ColorizeBasedOnLevel(levelColorMap map[level.Level]color.Color) IProcessor
- func ColorizeBasedOnWord(wordColorMap map[string]color.Color) IProcessor
- func Decolourizer() IProcessor
- func ErrorSimulator(msg string) IProcessor
- func ForceBasedOnLevel(levels ...level.Level) IProcessor
- func MuteBasedOnLevel(levels ...level.Level) IProcessor
- func New(name string, f RunFunc) IProcessor
- func PrefixBasedOnMask(timestampFormat string) IProcessor
- func PrefixBasedOnMaskExceptForLevels(timestampFormat string, levels ...level.Level) IProcessor
- func Prefixer(prefix string) IProcessor
- func PrintOnlyAtLevel(levels ...level.Level) IProcessor
- func PrintOnlyIfNotTaggedWith(tags ...string) IProcessor
- func PrintOnlyIfTagged(tag string) IProcessor
- func Suffixer(suffix string) IProcessor
- type ProcessingError
- type RunFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type IProcessor ¶
type IProcessor interface { meta.IMeta // String interface. String() string // Run the processor, if enabled. Run(m message.IMessage) error }
IProcessor specifies what a processor does.
func ChangeFirstCharCase ¶
func ChangeFirstCharCase(casing Casing) IProcessor
ChangeFirstCharCase changes message content's first char to the specified case.
Notes: - `casing` because `case` is a reserved word. - Order matters! If this comes after another processor like the Prefixer, it will change the case of the first char of the Prefix mask, not the message content!
func ColorizeBasedOnLevel ¶
func ColorizeBasedOnLevel(levelColorMap map[level.Level]color.Color) IProcessor
ColorizeBasedOnLevel colorize messages based on the specified levels.
func ColorizeBasedOnWord ¶
func ColorizeBasedOnWord(wordColorMap map[string]color.Color) IProcessor
ColorizeBasedOnWord colorize a messages with the specified colors if a message contains a specific word.
func ErrorSimulator ¶
func ErrorSimulator(msg string) IProcessor
ErrorSimulator simulates an error in the pipeline.
func ForceBasedOnLevel ¶
func ForceBasedOnLevel(levels ...level.Level) IProcessor
ForceBasedOnLevel force messages to be printed based on the specified levels.
func MuteBasedOnLevel ¶
func MuteBasedOnLevel(levels ...level.Level) IProcessor
MuteBasedOnLevel mute messages based on the specified levels.
func PrefixBasedOnMask ¶
func PrefixBasedOnMask(timestampFormat string) IProcessor
PrefixBasedOnMask prefixes messages with the predefined mask.
Example: 2021-06-22 12:51:46.089 [80819] [CLI] [Info].
func PrefixBasedOnMaskExceptForLevels ¶
func PrefixBasedOnMaskExceptForLevels(timestampFormat string, levels ...level.Level) IProcessor
PrefixBasedOnMaskExceptForLevels is a specialized version of the `PrefixBasedOnMask`. It prefixes all messages, except for the specified levels.
func Prefixer ¶
func Prefixer(prefix string) IProcessor
Prefixer prefixes a message with the specified `prefix`.
func PrintOnlyAtLevel ¶
func PrintOnlyAtLevel(levels ...level.Level) IProcessor
PrintOnlyAtLevel prints only if message is at the specified level.
func PrintOnlyIfNotTaggedWith ¶ added in v1.6.6
func PrintOnlyIfNotTaggedWith(tags ...string) IProcessor
PrintOnlyIfNotTaggedWith prints only if message contains the specified tag.
func PrintOnlyIfTagged ¶
func PrintOnlyIfTagged(tag string) IProcessor
PrintOnlyIfTagged prints only if message contains the specified tag.
func Suffixer ¶
func Suffixer(suffix string) IProcessor
Suffixer suffixes a message with the specified `suffix`.
type ProcessingError ¶
type ProcessingError struct { // Cause is the underlying case of the failure. Cause error // Message when the failured happened. Message message.IMessage // OutputName is the name of the output in-use. OutputName string // ProcessorName is the name of the processor in-use. ProcessorName string }
ProcessingError is thrown when a processor fails.
func (*ProcessingError) Error ¶
func (p *ProcessingError) Error() string
Error interface implementation.