filters

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByExcluding

func ByExcluding(predicate func(*core.LogEvent) bool) core.LogEventFilter

ByExcluding creates a filter that excludes events matching the predicate.

func ByIncluding

func ByIncluding(predicate func(*core.LogEvent) bool) core.LogEventFilter

ByIncluding creates a filter that includes only events matching the predicate.

func MatchAllProperties

func MatchAllProperties(matchers ...core.LogEventFilter) core.LogEventFilter

MatchAllProperties creates a filter that matches when all properties match.

func MatchAnyProperty

func MatchAnyProperty(matchers ...core.LogEventFilter) core.LogEventFilter

MatchAnyProperty creates a filter that matches when any of the properties match.

func MatchProperty

func MatchProperty(propertyName string, expectedValue any) core.LogEventFilter

MatchProperty creates a filter that matches when a property equals a specific value.

func MatchPropertyAbsent

func MatchPropertyAbsent(propertyName string) core.LogEventFilter

MatchPropertyAbsent creates a filter that matches when a property does not exist.

func MatchPropertyContains

func MatchPropertyContains(propertyName string, substring string) core.LogEventFilter

MatchPropertyContains creates a filter that matches when a property contains a substring.

func MatchPropertyExists

func MatchPropertyExists(propertyName string) core.LogEventFilter

MatchPropertyExists creates a filter that matches when a property exists.

func MatchPropertyRegex

func MatchPropertyRegex(propertyName string, pattern string) core.LogEventFilter

MatchPropertyRegex creates a filter that matches when a property matches a regex pattern.

func MinimumLevelFilter

func MinimumLevelFilter(level core.LogEventLevel) core.LogEventFilter

MinimumLevelFilter is a convenience function that creates a level filter.

func When

func When(condition bool, filter core.LogEventFilter) core.LogEventFilter

When creates a conditional filter that applies when the condition is true.

Types

type CompositeFilter

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

CompositeFilter combines multiple filters with AND logic.

func NewCompositeFilter

func NewCompositeFilter(filters ...core.LogEventFilter) *CompositeFilter

NewCompositeFilter creates a filter that requires all sub-filters to pass.

func (*CompositeFilter) Add

func (f *CompositeFilter) Add(filter core.LogEventFilter)

Add adds a new filter to the composite.

func (*CompositeFilter) IsEnabled

func (f *CompositeFilter) IsEnabled(event *core.LogEvent) bool

IsEnabled returns true only if all sub-filters return true.

type ExpressionFilter

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

ExpressionFilter filters log events based on property values.

func NewExpressionFilter

func NewExpressionFilter(propertyName string, matcher func(any) bool) *ExpressionFilter

NewExpressionFilter creates a filter that matches based on a property value.

func (*ExpressionFilter) IsEnabled

func (f *ExpressionFilter) IsEnabled(event *core.LogEvent) bool

IsEnabled returns true if the property matches the expression.

type HashSamplingFilter

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

HashSamplingFilter samples events based on a hash of a property value. This ensures consistent sampling for the same property values.

func NewHashSamplingFilter

func NewHashSamplingFilter(propertyName string, rate float32) *HashSamplingFilter

NewHashSamplingFilter creates a filter that samples based on property value hash.

func (*HashSamplingFilter) IsEnabled

func (f *HashSamplingFilter) IsEnabled(event *core.LogEvent) bool

IsEnabled returns true if the property hash falls within the sampling range.

type LevelFilter

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

LevelFilter filters log events based on their level.

func NewLevelFilter

func NewLevelFilter(minimumLevel core.LogEventLevel) *LevelFilter

NewLevelFilter creates a filter that only allows events at or above the specified level.

func (*LevelFilter) IsEnabled

func (f *LevelFilter) IsEnabled(event *core.LogEvent) bool

IsEnabled returns true if the event level is at or above the minimum level.

type NotFilter

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

NotFilter inverts the result of another filter.

func NewNotFilter

func NewNotFilter(inner core.LogEventFilter) *NotFilter

NewNotFilter creates a filter that inverts another filter's result.

func (*NotFilter) IsEnabled

func (f *NotFilter) IsEnabled(event *core.LogEvent) bool

IsEnabled returns the inverse of the inner filter's result.

type OrFilter

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

OrFilter combines multiple filters with OR logic.

func NewOrFilter

func NewOrFilter(filters ...core.LogEventFilter) *OrFilter

NewOrFilter creates a filter that passes if any sub-filter passes.

func (*OrFilter) IsEnabled

func (f *OrFilter) IsEnabled(event *core.LogEvent) bool

IsEnabled returns true if any sub-filter returns true.

type PredicateFilter

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

PredicateFilter filters log events based on a custom predicate function.

func NewPredicateFilter

func NewPredicateFilter(predicate func(*core.LogEvent) bool) *PredicateFilter

NewPredicateFilter creates a filter that uses a custom predicate function.

func (*PredicateFilter) IsEnabled

func (f *PredicateFilter) IsEnabled(event *core.LogEvent) bool

IsEnabled returns the result of the predicate function.

type RateLimitFilter

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

RateLimitFilter limits the number of events per time window.

func NewRateLimitFilter

func NewRateLimitFilter(maxEvents int, windowNanos int64) *RateLimitFilter

NewRateLimitFilter creates a filter that limits events to maxEvents per window.

func (*RateLimitFilter) IsEnabled

func (f *RateLimitFilter) IsEnabled(event *core.LogEvent) bool

IsEnabled returns true if the event is within the rate limit.

type SamplingFilter

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

SamplingFilter filters log events based on sampling rules.

func NewSamplingFilter

func NewSamplingFilter(rate float32) *SamplingFilter

NewSamplingFilter creates a filter that samples events at the specified rate. Rate should be between 0.0 (no events) and 1.0 (all events).

func (*SamplingFilter) IsEnabled

func (f *SamplingFilter) IsEnabled(event *core.LogEvent) bool

IsEnabled returns true for a percentage of events based on the sampling rate.

type SourceContextLevelFilter

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

SourceContextLevelFilter filters log events based on source context and minimum level.

func NewSourceContextLevelFilter

func NewSourceContextLevelFilter(defaultLevel core.LogEventLevel, overrides map[string]core.LogEventLevel) *SourceContextLevelFilter

NewSourceContextLevelFilter creates a new filter with source context level overrides.

func (*SourceContextLevelFilter) AddOverride

func (f *SourceContextLevelFilter) AddOverride(sourceContext string, level core.LogEventLevel)

AddOverride adds or updates a source context level override.

func (*SourceContextLevelFilter) IsEnabled

func (f *SourceContextLevelFilter) IsEnabled(event *core.LogEvent) bool

IsEnabled determines if a log event should be processed based on its source context and level.

func (*SourceContextLevelFilter) RemoveOverride

func (f *SourceContextLevelFilter) RemoveOverride(sourceContext string)

RemoveOverride removes a source context level override.

func (*SourceContextLevelFilter) SetDefaultLevel

func (f *SourceContextLevelFilter) SetDefaultLevel(level core.LogEventLevel)

SetDefaultLevel updates the default minimum level.

Jump to

Keyboard shortcuts

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