processor

package
v1.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package processor defines the pipeline components responsible for modifying, filtering, or enriching log messages as they flow through the system. It follows a modular design where multiple processors can be chained together.

Package processor provides a pipeline-based architecture for manipulating and filtering log messages as they flow from the source to the sinks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DedupeProcessor

type DedupeProcessor struct {
	// contains filtered or unexported fields
}

DedupeProcessor prevents consecutive identical log messages from the same container from cluttering the output. This is particularly useful for containers that emit repetitive "heartbeat" or "waiting" logs.

func NewDedupeProcessor

func NewDedupeProcessor() *DedupeProcessor

NewDedupeProcessor creates a new DedupeProcessor with an empty tracking map.

func (*DedupeProcessor) Process

func (d *DedupeProcessor) Process(msg *types.LogMessage) (*types.LogMessage, bool)

Process checks if the current message is identical to the last one seen for this specific container. If it is, it returns false to drop the message.

type FilterProcessor

type FilterProcessor struct {
	// contains filtered or unexported fields
}

FilterProcessor implements the logic for dropping or keeping log messages based on user-defined criteria. It supports literal substring matching, exclusion patterns, and complex regular expressions.

func NewFilterProcessor

func NewFilterProcessor(filter, exclude string, regexFilter *regexp.Regexp) *FilterProcessor

NewFilterProcessor creates a new instance of FilterProcessor. It pre-processes the filter and exclude strings by converting them to lowercase to ensure case-insensitive matching during the processing phase.

func (*FilterProcessor) Process

func (f *FilterProcessor) Process(msg *types.LogMessage) (*types.LogMessage, bool)

Process evaluates a log message against the configured filters. It returns the message and 'true' if it passes all filters, or 'nil' and 'false' if it should be dropped.

The evaluation order is: 1. Exclusion (Literal match) 2. Regular Expression match 3. Inclusion (Literal match)

type LevelProcessor

type LevelProcessor struct {
	// contains filtered or unexported fields
}

LevelProcessor filters log messages based on their severity level (e.g., INFO, ERROR). It performs a case-insensitive check for the existence of the level string within the log message.

func NewLevelProcessor

func NewLevelProcessor(allowedLevels []string) *LevelProcessor

NewLevelProcessor creates a new LevelProcessor with the specified allowed levels. All provided levels are automatically normalized to uppercase for consistent matching.

func (*LevelProcessor) Process

func (p *LevelProcessor) Process(msg *types.LogMessage) (*types.LogMessage, bool)

Process checks if the log message contains any of the allowed severity levels. If allowedLevels is empty, all messages are passed through. The matching is case-insensitive.

type LimitProcessor

type LimitProcessor struct {
	// contains filtered or unexported fields
}

LimitProcessor stops processing log messages after a certain threshold is reached. It is useful for implementing commands like 'run' which should exit after N logs.

func NewLimitProcessor

func NewLimitProcessor(max int, onLimitReached func()) *LimitProcessor

NewLimitProcessor creates a new LimitProcessor with the specified maximum count. If max is <= 0, the limit is disabled.

func (*LimitProcessor) Process

func (p *LimitProcessor) Process(msg *types.LogMessage) (*types.LogMessage, bool)

Process increments the internal counter and checks against the maximum. If the limit is exceeded, it executes the 'done' callback and drops the message.

type Processor

type Processor interface {
	// Process handles a single log message.
	// It returns the (potentially modified) message and a boolean 'keep'.
	// If 'keep' is false, the message is dropped and will not proceed further
	// in the processing pipeline.
	Process(msg *types.LogMessage) (processed *types.LogMessage, keep bool)
}

Processor defines the interface for components that can modify or filter log messages. Implementations can be chained together to create complex log processing pipelines.

type RedactProcessor

type RedactProcessor struct {
	// contains filtered or unexported fields
}

RedactProcessor automatically masks sensitive information in log messages. It uses a set of pre-defined regular expressions to find and replace data like emails, IP addresses, and authentication tokens with asterisks.

func NewRedactProcessor

func NewRedactProcessor() *RedactProcessor

NewRedactProcessor creates a new RedactProcessor with default redaction rules.

func (*RedactProcessor) Process

func (r *RedactProcessor) Process(msg *types.LogMessage) (*types.LogMessage, bool)

Process scans the log message text and replaces any sensitive matches with "***". It always returns true as it only modifies the message content and never drops it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL