Documentation
¶
Index ¶
- func AndPredicate(predicates ...func(*core.LogEvent) bool) func(*core.LogEvent) bool
- func LevelPredicate(minLevel core.LogEventLevel) func(*core.LogEvent) bool
- func NotPredicate(predicate func(*core.LogEvent) bool) func(*core.LogEvent) bool
- func OrPredicate(predicates ...func(*core.LogEvent) bool) func(*core.LogEvent) bool
- func PropertyPredicate(propertyName string) func(*core.LogEvent) bool
- func PropertyValuePredicate(propertyName string, expectedValue interface{}) func(*core.LogEvent) bool
- func StartMetricsServer(addr string, exporter *RouterMetricsExporter) error
- type AsyncMetrics
- type AsyncOptions
- type AsyncSink
- type BufferedLogEvent
- type CircuitBreakerOptions
- type CircuitBreakerSink
- type CircuitBreakerStats
- type CircuitState
- type Color
- type ConditionalSink
- type ConsoleSink
- func NewConsoleSink() *ConsoleSink
- func NewConsoleSinkWithProperties() *ConsoleSink
- func NewConsoleSinkWithTemplate(template string) (*ConsoleSink, error)
- func NewConsoleSinkWithTemplateAndTheme(template string, theme *ConsoleTheme) (*ConsoleSink, error)
- func NewConsoleSinkWithTheme(theme *ConsoleTheme) *ConsoleSink
- func NewConsoleSinkWithWriter(w io.Writer) *ConsoleSink
- func (cs *ConsoleSink) Close() error
- func (cs *ConsoleSink) Emit(event *core.LogEvent)
- func (cs *ConsoleSink) EmitSimple(timestamp time.Time, level core.LogEventLevel, message string)
- func (cs *ConsoleSink) SetOutput(w io.Writer)
- func (cs *ConsoleSink) SetTheme(theme *ConsoleTheme)
- func (cs *ConsoleSink) SetUseColor(useColor bool)
- func (cs *ConsoleSink) ShowProperties(show bool)
- type ConsoleTheme
- type DurableOptions
- type DurableSink
- type ElasticsearchOption
- func WithElasticsearchAPIKey(apiKey string) ElasticsearchOption
- func WithElasticsearchBasicAuth(username, password string) ElasticsearchOption
- func WithElasticsearchBatchSize(size int) ElasticsearchOption
- func WithElasticsearchBatchTimeout(timeout time.Duration) ElasticsearchOption
- func WithElasticsearchDataStreams() ElasticsearchOption
- func WithElasticsearchIndex(index string) ElasticsearchOption
- func WithElasticsearchPipeline(pipeline string) ElasticsearchOption
- func WithElasticsearchURLs(urls ...string) ElasticsearchOption
- type ElasticsearchSink
- type FileSink
- type FilteredSink
- type HealthCheckWrapper
- type HealthCheckable
- type HealthStatus
- type MemorySink
- func (m *MemorySink) Clear()
- func (m *MemorySink) Close() error
- func (m *MemorySink) Count() int
- func (m *MemorySink) Emit(event *core.LogEvent)
- func (m *MemorySink) Events() []core.LogEvent
- func (m *MemorySink) FindEvents(predicate func(*core.LogEvent) bool) []core.LogEvent
- func (m *MemorySink) HasEvent(predicate func(*core.LogEvent) bool) bool
- func (ms *MemorySink) HealthCheck(ctx context.Context) error
- func (m *MemorySink) LastEvent() *core.LogEvent
- type OverflowStrategy
- type PredicateBuilder
- func (b *PredicateBuilder) And() *PredicateBuilder
- func (b *PredicateBuilder) Build() func(*core.LogEvent) bool
- func (b *PredicateBuilder) Custom(predicate func(*core.LogEvent) bool) *PredicateBuilder
- func (b *PredicateBuilder) Level(minLevel core.LogEventLevel) *PredicateBuilder
- func (b *PredicateBuilder) Not() *PredicateBuilder
- func (b *PredicateBuilder) Or() *PredicateBuilder
- func (b *PredicateBuilder) Property(name string) *PredicateBuilder
- func (b *PredicateBuilder) PropertyValue(name string, value interface{}) *PredicateBuilder
- type RollingFileOptions
- type RollingFileSink
- type RollingInterval
- type Route
- type RouteBuilder
- type RouteGroup
- type RouterMetricsExporter
- type RouterSink
- func (r *RouterSink) AddRoute(route Route)
- func (r *RouterSink) AddRouteGroup(group RouteGroup)
- func (r *RouterSink) CheckHealth(ctx context.Context) map[string]HealthStatus
- func (r *RouterSink) Close() error
- func (r *RouterSink) Emit(event *core.LogEvent)
- func (r *RouterSink) GetStats() RouterStats
- func (r *RouterSink) PeriodicHealthCheck(ctx context.Context, interval time.Duration, ...)
- func (r *RouterSink) RemoveRoute(name string) bool
- func (r *RouterSink) RemoveRouteGroup(groupName string) int
- func (r *RouterSink) ResetStats()
- func (r *RouterSink) TestEvent(event *core.LogEvent) []string
- type RouterStats
- type RoutingMode
- type SeqOption
- func WithSeqAPIKey(apiKey string) SeqOption
- func WithSeqBatchSize(size int) SeqOption
- func WithSeqBatchTimeout(timeout time.Duration) SeqOption
- func WithSeqCompression(enabled bool) SeqOption
- func WithSeqHTTPClient(client *http.Client) SeqOption
- func WithSeqRetry(count int, delay time.Duration) SeqOption
- type SeqSink
- type SplunkOption
- func WithSplunkBatchSize(size int) SplunkOption
- func WithSplunkBatchTimeout(timeout time.Duration) SplunkOption
- func WithSplunkHTTPClient(client *http.Client) SplunkOption
- func WithSplunkHost(host string) SplunkOption
- func WithSplunkIndex(index string) SplunkOption
- func WithSplunkSource(source string) SplunkOption
- func WithSplunkSourceType(sourceType string) SplunkOption
- type SplunkSink
- type TypedBatchingSink
- type TypedEvent
- type TypedSink
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AndPredicate ¶ added in v0.10.0
AndPredicate combines multiple predicates with AND logic.
func LevelPredicate ¶ added in v0.10.0
func LevelPredicate(minLevel core.LogEventLevel) func(*core.LogEvent) bool
LevelPredicate creates a predicate that matches events at or above the specified level.
func NotPredicate ¶ added in v0.10.0
NotPredicate inverts a predicate.
func OrPredicate ¶ added in v0.10.0
OrPredicate combines multiple predicates with OR logic.
func PropertyPredicate ¶ added in v0.10.0
PropertyPredicate creates a predicate that matches events containing a specific property.
func PropertyValuePredicate ¶ added in v0.10.0
func PropertyValuePredicate(propertyName string, expectedValue interface{}) func(*core.LogEvent) bool
PropertyValuePredicate creates a predicate that matches events with a specific property value.
func StartMetricsServer ¶ added in v0.10.0
func StartMetricsServer(addr string, exporter *RouterMetricsExporter) error
StartMetricsServer starts an HTTP server for Prometheus metrics.
Types ¶
type AsyncMetrics ¶
type AsyncMetrics struct {
Processed uint64 // Number of events successfully processed
Dropped uint64 // Number of events dropped due to overflow
Errors uint64 // Number of errors encountered
BufferSize int // Current number of events in buffer
BufferCap int // Buffer capacity
}
AsyncMetrics contains operational metrics for the async sink.
type AsyncOptions ¶
type AsyncOptions struct {
// BufferSize is the size of the channel buffer for log events.
BufferSize int
// OverflowStrategy defines what to do when the buffer is full.
OverflowStrategy OverflowStrategy
// FlushInterval is how often to flush events to the wrapped sink.
// 0 means flush immediately for each event.
FlushInterval time.Duration
// BatchSize is the maximum number of events to batch together.
// 0 means no batching.
BatchSize int
// OnError is called when an error occurs in the background worker.
OnError func(error)
// ShutdownTimeout is the maximum time to wait for pending events during shutdown.
ShutdownTimeout time.Duration
}
AsyncOptions configures the async sink wrapper.
type AsyncSink ¶
type AsyncSink struct {
// contains filtered or unexported fields
}
AsyncSink wraps another sink to provide asynchronous, non-blocking logging.
func NewAsyncSink ¶
func NewAsyncSink(wrapped core.LogEventSink, options AsyncOptions) *AsyncSink
NewAsyncSink creates a new async sink wrapper.
func (*AsyncSink) GetMetrics ¶
func (as *AsyncSink) GetMetrics() AsyncMetrics
GetMetrics returns metrics about the async sink operation.
type BufferedLogEvent ¶
type BufferedLogEvent struct {
Event *core.LogEvent `json:"event"`
Timestamp int64 `json:"timestamp"`
Sequence uint64 `json:"sequence"`
}
BufferedLogEvent represents a persisted log event with metadata.
type CircuitBreakerOptions ¶ added in v0.10.0
type CircuitBreakerOptions struct {
Name string
FailureThreshold int // Failures before opening circuit
SuccessThreshold int // Successes in half-open before closing
ResetTimeout time.Duration // Time before trying half-open
FallbackSink core.LogEventSink
OnStateChange func(from, to CircuitState)
}
CircuitBreakerOptions configures a circuit breaker sink.
type CircuitBreakerSink ¶ added in v0.10.0
type CircuitBreakerSink struct {
// contains filtered or unexported fields
}
CircuitBreakerSink wraps a sink with circuit breaker protection.
func NewCircuitBreakerSink ¶ added in v0.10.0
func NewCircuitBreakerSink(wrapped core.LogEventSink) *CircuitBreakerSink
NewCircuitBreakerSink creates a new circuit breaker sink with default options.
func NewCircuitBreakerSinkWithOptions ¶ added in v0.10.0
func NewCircuitBreakerSinkWithOptions(wrapped core.LogEventSink, opts CircuitBreakerOptions) *CircuitBreakerSink
NewCircuitBreakerSinkWithOptions creates a circuit breaker with custom options.
func (*CircuitBreakerSink) Close ¶ added in v0.10.0
func (cb *CircuitBreakerSink) Close() error
Close closes the wrapped sink.
func (*CircuitBreakerSink) Emit ¶ added in v0.10.0
func (cb *CircuitBreakerSink) Emit(event *core.LogEvent)
Emit sends the event through the circuit breaker.
func (*CircuitBreakerSink) GetState ¶ added in v0.10.0
func (cb *CircuitBreakerSink) GetState() CircuitState
GetState returns the current circuit state.
func (*CircuitBreakerSink) GetStats ¶ added in v0.10.0
func (cb *CircuitBreakerSink) GetStats() CircuitBreakerStats
GetStats returns current circuit breaker statistics.
func (*CircuitBreakerSink) HealthCheck ¶ added in v0.10.0
func (cb *CircuitBreakerSink) HealthCheck(ctx context.Context) error
HealthCheck checks the health of the wrapped sink if it supports it.
type CircuitBreakerStats ¶ added in v0.10.0
type CircuitBreakerStats struct {
State CircuitState
Failures int32
Successes int32
LastFailTime time.Time
}
CircuitBreakerStats contains circuit breaker statistics.
type CircuitState ¶ added in v0.10.0
type CircuitState int32
CircuitState represents the state of a circuit breaker.
const ( // CircuitClosed allows all events through (normal operation). CircuitClosed CircuitState = iota // CircuitOpen blocks all events (failure detected). CircuitOpen // CircuitHalfOpen allows one test event through. CircuitHalfOpen )
func (CircuitState) String ¶ added in v0.10.0
func (s CircuitState) String() string
type Color ¶
type Color string
Color represents an ANSI color code.
const ( // Basic colors ColorReset Color = "\033[0m" ColorBold Color = "\033[1m" ColorDim Color = "\033[2m" // Foreground colors ColorBlack Color = "\033[30m" ColorRed Color = "\033[31m" ColorGreen Color = "\033[32m" ColorYellow Color = "\033[33m" ColorBlue Color = "\033[34m" ColorMagenta Color = "\033[35m" ColorCyan Color = "\033[36m" ColorWhite Color = "\033[37m" // Bright foreground colors ColorBrightBlack Color = "\033[90m" ColorBrightRed Color = "\033[91m" ColorBrightGreen Color = "\033[92m" ColorBrightYellow Color = "\033[93m" ColorBrightBlue Color = "\033[94m" ColorBrightMagenta Color = "\033[95m" ColorBrightCyan Color = "\033[96m" ColorBrightWhite Color = "\033[97m" // Background colors ColorBgBlack Color = "\033[40m" ColorBgRed Color = "\033[41m" ColorBgGreen Color = "\033[42m" ColorBgYellow Color = "\033[43m" ColorBgBlue Color = "\033[44m" ColorBgMagenta Color = "\033[45m" ColorBgCyan Color = "\033[46m" ColorBgWhite Color = "\033[47m" )
func Ansi256BgColor ¶ added in v0.2.0
Ansi256BgColor creates an ANSI 256-background color code.
func Ansi256Color ¶ added in v0.2.0
Ansi256Color creates an ANSI 256-color code.
type ConditionalSink ¶ added in v0.10.0
type ConditionalSink struct {
// contains filtered or unexported fields
}
ConditionalSink routes events to a target sink based on a predicate. Events that don't match the predicate are discarded with zero overhead.
func NewConditionalSink ¶ added in v0.10.0
func NewConditionalSink(predicate func(*core.LogEvent) bool, target core.LogEventSink) *ConditionalSink
NewConditionalSink creates a sink that only forwards events matching the predicate.
func NewNamedConditionalSink ¶ added in v0.10.0
func NewNamedConditionalSink(name string, predicate func(*core.LogEvent) bool, target core.LogEventSink) *ConditionalSink
NewNamedConditionalSink creates a named conditional sink for better debugging.
func (*ConditionalSink) Close ¶ added in v0.10.0
func (s *ConditionalSink) Close() error
Close closes the target sink.
func (*ConditionalSink) Emit ¶ added in v0.10.0
func (s *ConditionalSink) Emit(event *core.LogEvent)
Emit forwards the event to the target sink if the predicate returns true.
type ConsoleSink ¶
type ConsoleSink struct {
// contains filtered or unexported fields
}
ConsoleSink writes log events to the console.
func NewConsoleSink ¶
func NewConsoleSink() *ConsoleSink
NewConsoleSink creates a new console sink that writes to stdout.
func NewConsoleSinkWithProperties ¶
func NewConsoleSinkWithProperties() *ConsoleSink
NewConsoleSinkWithProperties creates a new console sink that displays properties.
func NewConsoleSinkWithTemplate ¶ added in v0.2.0
func NewConsoleSinkWithTemplate(template string) (*ConsoleSink, error)
NewConsoleSinkWithTemplate creates a new console sink with a custom output template.
func NewConsoleSinkWithTemplateAndTheme ¶ added in v0.2.0
func NewConsoleSinkWithTemplateAndTheme(template string, theme *ConsoleTheme) (*ConsoleSink, error)
NewConsoleSinkWithTemplateAndTheme creates a new console sink with both template and theme.
func NewConsoleSinkWithTheme ¶
func NewConsoleSinkWithTheme(theme *ConsoleTheme) *ConsoleSink
NewConsoleSinkWithTheme creates a new console sink with a custom theme.
func NewConsoleSinkWithWriter ¶
func NewConsoleSinkWithWriter(w io.Writer) *ConsoleSink
NewConsoleSinkWithWriter creates a new console sink with a custom writer.
func (*ConsoleSink) Close ¶
func (cs *ConsoleSink) Close() error
Close releases any resources held by the sink.
func (*ConsoleSink) Emit ¶
func (cs *ConsoleSink) Emit(event *core.LogEvent)
Emit writes the log event to the console.
func (*ConsoleSink) EmitSimple ¶
func (cs *ConsoleSink) EmitSimple(timestamp time.Time, level core.LogEventLevel, message string)
EmitSimple writes a simple log message without allocations.
func (*ConsoleSink) SetOutput ¶ added in v0.5.0
func (cs *ConsoleSink) SetOutput(w io.Writer)
SetOutput sets the output writer for the console sink.
func (*ConsoleSink) SetTheme ¶
func (cs *ConsoleSink) SetTheme(theme *ConsoleTheme)
SetTheme updates the console theme.
func (*ConsoleSink) SetUseColor ¶
func (cs *ConsoleSink) SetUseColor(useColor bool)
SetUseColor enables or disables color output.
func (*ConsoleSink) ShowProperties ¶
func (cs *ConsoleSink) ShowProperties(show bool)
ShowProperties enables or disables property display.
type ConsoleTheme ¶
type ConsoleTheme struct {
// Level colors
VerboseColor Color
DebugColor Color
InformationColor Color
WarningColor Color
ErrorColor Color
FatalColor Color
// Element colors
TimestampColor Color
MessageColor Color
PropertyKeyColor Color
PropertyValColor Color
BracketColor Color // Color for brackets and delimiters
// Formatting
LevelFormat string // Format string for level, e.g., "[%s]" or "%s:"
TimestampFormat string // Time format string
PropertyFormat string // Format for properties, e.g., "%s=%v"
}
ConsoleTheme defines the colors and formatting for console output.
func AutoLiterateTheme ¶ added in v0.2.0
func AutoLiterateTheme() *ConsoleTheme
AutoLiterateTheme returns LiterateTheme for 256-color terminals or Literate8ColorTheme otherwise.
func DefaultTheme ¶
func DefaultTheme() *ConsoleTheme
DefaultTheme returns the default console theme.
func DevTheme ¶
func DevTheme() *ConsoleTheme
DevTheme returns a developer-friendly theme with more information.
func LiteTheme ¶
func LiteTheme() *ConsoleTheme
LiteTheme returns a minimalist theme with subtle colors.
func Literate8ColorTheme ¶ added in v0.2.0
func Literate8ColorTheme() *ConsoleTheme
Literate8ColorTheme returns a Literate-inspired theme using only basic 8 ANSI colors. This is useful for terminals that don't support 256 colors.
func LiterateTheme ¶ added in v0.2.0
func LiterateTheme() *ConsoleTheme
LiterateTheme returns the Serilog Literate theme using ANSI 256 colors. This theme provides readable, non-garish colors that are easy on the eyes.
func NoColorTheme ¶
func NoColorTheme() *ConsoleTheme
NoColorTheme returns a theme without any colors.
func (*ConsoleTheme) GetLevelColor ¶
func (t *ConsoleTheme) GetLevelColor(level core.LogEventLevel) Color
GetLevelColor returns the color for a specific log level.
type DurableOptions ¶
type DurableOptions struct {
// BufferPath is the directory where buffer files are stored.
BufferPath string
// MaxBufferSize is the maximum size in bytes of the buffer file.
MaxBufferSize int64
// MaxBufferFiles is the maximum number of buffer files to keep.
MaxBufferFiles int
// RetryInterval is how often to attempt delivery to the wrapped sink.
RetryInterval time.Duration
// BatchSize is the number of events to process in each retry batch.
BatchSize int
// OnError is called when an error occurs in the background worker.
OnError func(error)
// ShutdownTimeout is the maximum time to wait during shutdown.
ShutdownTimeout time.Duration
// FlushInterval is how often to flush the buffer file to disk.
FlushInterval time.Duration
// ChannelBufferSize is the size of the internal event channel.
// Defaults to 10000 if not specified.
ChannelBufferSize int
}
DurableOptions configures the durable buffer sink.
type DurableSink ¶
type DurableSink struct {
// contains filtered or unexported fields
}
DurableSink wraps another sink to provide persistent buffering when the sink fails.
func NewDurableSink ¶
func NewDurableSink(wrapped core.LogEventSink, options DurableOptions) (*DurableSink, error)
NewDurableSink creates a new durable buffer sink.
func (*DurableSink) Close ¶
func (ds *DurableSink) Close() error
Close shuts down the durable sink and flushes remaining events.
func (*DurableSink) Emit ¶
func (ds *DurableSink) Emit(event *core.LogEvent)
Emit sends a log event through the durable buffer.
func (*DurableSink) GetMetrics ¶
func (ds *DurableSink) GetMetrics() map[string]uint64
GetMetrics returns current metrics for monitoring.
func (*DurableSink) IsHealthy ¶
func (ds *DurableSink) IsHealthy() bool
IsHealthy returns true if the wrapped sink is currently healthy.
type ElasticsearchOption ¶
type ElasticsearchOption func(*ElasticsearchSink)
ElasticsearchOption configures an Elasticsearch sink
func WithElasticsearchAPIKey ¶
func WithElasticsearchAPIKey(apiKey string) ElasticsearchOption
WithElasticsearchAPIKey sets the API key for authentication
func WithElasticsearchBasicAuth ¶
func WithElasticsearchBasicAuth(username, password string) ElasticsearchOption
WithElasticsearchBasicAuth sets username and password for basic authentication
func WithElasticsearchBatchSize ¶
func WithElasticsearchBatchSize(size int) ElasticsearchOption
WithElasticsearchBatchSize sets the batch size
func WithElasticsearchBatchTimeout ¶
func WithElasticsearchBatchTimeout(timeout time.Duration) ElasticsearchOption
WithElasticsearchBatchTimeout sets the batch timeout
func WithElasticsearchDataStreams ¶
func WithElasticsearchDataStreams() ElasticsearchOption
WithElasticsearchDataStreams enables data streams instead of indices
func WithElasticsearchIndex ¶
func WithElasticsearchIndex(index string) ElasticsearchOption
WithElasticsearchIndex sets the index name or data stream name
func WithElasticsearchPipeline ¶
func WithElasticsearchPipeline(pipeline string) ElasticsearchOption
WithElasticsearchPipeline sets the ingest pipeline to use
func WithElasticsearchURLs ¶
func WithElasticsearchURLs(urls ...string) ElasticsearchOption
WithElasticsearchURLs sets multiple Elasticsearch URLs for load balancing
type ElasticsearchSink ¶
type ElasticsearchSink struct {
// contains filtered or unexported fields
}
ElasticsearchSink writes log events to Elasticsearch
func NewElasticsearchSink ¶
func NewElasticsearchSink(url string, opts ...ElasticsearchOption) (*ElasticsearchSink, error)
NewElasticsearchSink creates a new Elasticsearch sink
func (*ElasticsearchSink) Emit ¶
func (es *ElasticsearchSink) Emit(event *core.LogEvent)
Emit writes a log event to the sink
type FileSink ¶
type FileSink struct {
// contains filtered or unexported fields
}
FileSink writes log events to a file.
func NewFileSink ¶
NewFileSink creates a new file sink.
func NewFileSinkWithOptions ¶
NewFileSinkWithOptions creates a new file sink with custom options.
func NewFileSinkWithTemplate ¶ added in v0.2.0
NewFileSinkWithTemplate creates a new file sink with a custom output template.
func (*FileSink) EmitSimple ¶
EmitSimple writes a simple log message without allocations.
type FilteredSink ¶
type FilteredSink[T any] struct { // contains filtered or unexported fields }
FilteredSink applies type-safe filtering
func NewFilteredSink ¶
func NewFilteredSink[T any](innerSink TypedSink[T], predicate func(*core.LogEvent, T) bool) *FilteredSink[T]
NewFilteredSink creates a new filtered sink
type HealthCheckWrapper ¶ added in v0.10.0
type HealthCheckWrapper struct {
// contains filtered or unexported fields
}
HealthCheckWrapper wraps a sink with a simple health check.
func NewHealthCheckWrapper ¶ added in v0.10.0
func NewHealthCheckWrapper(sink core.LogEventSink, checker func(context.Context) error) *HealthCheckWrapper
func (*HealthCheckWrapper) Close ¶ added in v0.10.0
func (h *HealthCheckWrapper) Close() error
func (*HealthCheckWrapper) Emit ¶ added in v0.10.0
func (h *HealthCheckWrapper) Emit(event *core.LogEvent)
func (*HealthCheckWrapper) HealthCheck ¶ added in v0.10.0
func (h *HealthCheckWrapper) HealthCheck(ctx context.Context) error
type HealthCheckable ¶ added in v0.10.0
HealthCheckable interface for sinks that support health checks.
type HealthStatus ¶ added in v0.10.0
HealthStatus represents the health status of a route.
type MemorySink ¶
type MemorySink struct {
// contains filtered or unexported fields
}
MemorySink stores log events in memory for testing purposes.
func (*MemorySink) Count ¶
func (m *MemorySink) Count() int
Count returns the number of stored events.
func (*MemorySink) Emit ¶
func (m *MemorySink) Emit(event *core.LogEvent)
Emit stores the event in memory.
func (*MemorySink) Events ¶
func (m *MemorySink) Events() []core.LogEvent
Events returns a copy of all stored events.
func (*MemorySink) FindEvents ¶
FindEvents returns events that match the given predicate.
func (*MemorySink) HasEvent ¶
func (m *MemorySink) HasEvent(predicate func(*core.LogEvent) bool) bool
HasEvent returns true if any event matches the predicate.
func (*MemorySink) HealthCheck ¶ added in v0.10.0
func (ms *MemorySink) HealthCheck(ctx context.Context) error
Health check for memory sinks (always healthy)
func (*MemorySink) LastEvent ¶
func (m *MemorySink) LastEvent() *core.LogEvent
LastEvent returns the most recent event, or nil if no events.
type OverflowStrategy ¶
type OverflowStrategy int
OverflowStrategy defines what to do when the async buffer is full.
const ( // OverflowBlock blocks the caller until space is available. OverflowBlock OverflowStrategy = iota // OverflowDrop drops the newest events when the buffer is full. OverflowDrop // OverflowDropOldest drops the oldest events to make room for new ones. OverflowDropOldest )
type PredicateBuilder ¶ added in v0.10.0
type PredicateBuilder struct {
// contains filtered or unexported fields
}
PredicateBuilder provides a fluent API for building complex predicates.
func AuditEvents ¶ added in v0.10.0
func AuditEvents() *PredicateBuilder
AuditEvents creates a builder for audit events.
func CriticalAlerts ¶ added in v0.10.0
func CriticalAlerts() *PredicateBuilder
CriticalAlerts creates a builder for critical alerts.
func ErrorsOnly ¶ added in v0.10.0
func ErrorsOnly() *PredicateBuilder
ErrorsOnly creates a builder for error-level events.
func MetricEvents ¶ added in v0.10.0
func MetricEvents() *PredicateBuilder
MetricEvents creates a builder for metric events.
func NewPredicateBuilder ¶ added in v0.10.0
func NewPredicateBuilder() *PredicateBuilder
NewPredicateBuilder creates a new predicate builder.
func ProductionOnly ¶ added in v0.10.0
func ProductionOnly() *PredicateBuilder
ProductionOnly creates a builder for production environment events.
func (*PredicateBuilder) And ¶ added in v0.10.0
func (b *PredicateBuilder) And() *PredicateBuilder
And adds an AND operator for the next predicate.
func (*PredicateBuilder) Build ¶ added in v0.10.0
func (b *PredicateBuilder) Build() func(*core.LogEvent) bool
Build creates the final predicate function. The builder uses left-to-right evaluation with AND having higher precedence than OR.
func (*PredicateBuilder) Custom ¶ added in v0.10.0
func (b *PredicateBuilder) Custom(predicate func(*core.LogEvent) bool) *PredicateBuilder
Custom adds a custom predicate function.
func (*PredicateBuilder) Level ¶ added in v0.10.0
func (b *PredicateBuilder) Level(minLevel core.LogEventLevel) *PredicateBuilder
Level adds a level-based predicate.
func (*PredicateBuilder) Not ¶ added in v0.10.0
func (b *PredicateBuilder) Not() *PredicateBuilder
Not negates the next predicate.
func (*PredicateBuilder) Or ¶ added in v0.10.0
func (b *PredicateBuilder) Or() *PredicateBuilder
Or adds an OR operator for the next predicate.
func (*PredicateBuilder) Property ¶ added in v0.10.0
func (b *PredicateBuilder) Property(name string) *PredicateBuilder
Property adds a property existence predicate.
func (*PredicateBuilder) PropertyValue ¶ added in v0.10.0
func (b *PredicateBuilder) PropertyValue(name string, value interface{}) *PredicateBuilder
PropertyValue adds a property value predicate.
type RollingFileOptions ¶
type RollingFileOptions struct {
// FilePath is the path to the log file.
FilePath string
// MaxFileSize is the maximum size of a file before rolling (in bytes).
// 0 means no size limit.
MaxFileSize int64
// RollingInterval defines time-based rolling.
RollingInterval RollingInterval
// RetainFileCount is the number of rolled files to keep.
// 0 means keep all files.
RetainFileCount int
// CompressRolledFiles enables gzip compression for rolled files.
CompressRolledFiles bool
// Formatter to use for formatting log events.
Formatter interface {
Format(event *core.LogEvent) ([]byte, error)
}
// BufferSize for file writes (default 64KB).
BufferSize int
}
RollingFileOptions configures the rolling file sink.
type RollingFileSink ¶
type RollingFileSink struct {
// contains filtered or unexported fields
}
RollingFileSink writes log events to files with rolling support.
func NewRollingFileSink ¶
func NewRollingFileSink(options RollingFileOptions) (*RollingFileSink, error)
NewRollingFileSink creates a new rolling file sink.
func (*RollingFileSink) Close ¶
func (rfs *RollingFileSink) Close() error
Close closes the file sink.
func (*RollingFileSink) Emit ¶
func (rfs *RollingFileSink) Emit(event *core.LogEvent)
Emit writes a log event to the file.
type RollingInterval ¶
type RollingInterval int
RollingInterval defines when to roll files based on time.
const ( // RollingIntervalNone disables time-based rolling. RollingIntervalNone RollingInterval = iota // RollingIntervalHourly rolls files every hour. RollingIntervalHourly // RollingIntervalDaily rolls files every day. RollingIntervalDaily // RollingIntervalWeekly rolls files every week. RollingIntervalWeekly // RollingIntervalMonthly rolls files every month. RollingIntervalMonthly )
type Route ¶ added in v0.10.0
type Route struct {
Name string
Priority int // Lower values = higher priority (0 = highest)
Predicate func(*core.LogEvent) bool
Sink core.LogEventSink
}
Route represents a named routing rule with optional priority.
func AuditRoute ¶ added in v0.10.0
func AuditRoute(name string, sink core.LogEventSink) Route
AuditRoute creates a route for events with an "Audit" property.
func ErrorRoute ¶ added in v0.10.0
func ErrorRoute(name string, sink core.LogEventSink) Route
ErrorRoute creates a route for error-level events.
func MetricRoute ¶ added in v0.10.0
func MetricRoute(name string, sink core.LogEventSink) Route
MetricRoute creates a route for events with a "Metric" property.
type RouteBuilder ¶ added in v0.10.0
type RouteBuilder struct {
// contains filtered or unexported fields
}
RouteBuilder provides a fluent API for building routes.
func NewRoute ¶ added in v0.10.0
func NewRoute(name string) *RouteBuilder
NewRoute starts building a new route with the given name.
func (*RouteBuilder) To ¶ added in v0.10.0
func (b *RouteBuilder) To(sink core.LogEventSink) Route
To completes the route with the target sink.
func (*RouteBuilder) When ¶ added in v0.10.0
func (b *RouteBuilder) When(predicate func(*core.LogEvent) bool) *RouteBuilder
When sets the predicate for the route.
func (*RouteBuilder) WithPriority ¶ added in v0.10.0
func (b *RouteBuilder) WithPriority(priority int) *RouteBuilder
WithPriority sets the priority for the route (lower = higher priority).
type RouteGroup ¶ added in v0.10.0
RouteGroup represents a named collection of related routes.
func NewRouteGroup ¶ added in v0.10.0
func NewRouteGroup(name string, routes ...Route) RouteGroup
NewRouteGroup creates a new route group with the specified name and routes.
type RouterMetricsExporter ¶ added in v0.10.0
type RouterMetricsExporter struct {
// contains filtered or unexported fields
}
RouterMetricsExporter exports router statistics in Prometheus format.
func NewRouterMetricsExporter ¶ added in v0.10.0
func NewRouterMetricsExporter() *RouterMetricsExporter
NewRouterMetricsExporter creates a new metrics exporter.
func (*RouterMetricsExporter) RegisterRouter ¶ added in v0.10.0
func (e *RouterMetricsExporter) RegisterRouter(name string, router *RouterSink)
RegisterRouter registers a router for metrics export.
func (*RouterMetricsExporter) ServeHTTP ¶ added in v0.10.0
func (e *RouterMetricsExporter) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler for Prometheus scraping.
func (*RouterMetricsExporter) UnregisterRouter ¶ added in v0.10.0
func (e *RouterMetricsExporter) UnregisterRouter(name string)
UnregisterRouter removes a router from metrics export.
type RouterSink ¶ added in v0.10.0
type RouterSink struct {
// contains filtered or unexported fields
}
RouterSink routes events to different sinks based on configured routes.
func NewRouterSink ¶ added in v0.10.0
func NewRouterSink(mode RoutingMode, routes ...Route) *RouterSink
NewRouterSink creates a new router sink with the specified routing mode.
func NewRouterSinkWithDefault ¶ added in v0.10.0
func NewRouterSinkWithDefault(mode RoutingMode, defaultSink core.LogEventSink, routes ...Route) *RouterSink
NewRouterSinkWithDefault creates a router with a default sink for non-matching events.
func (*RouterSink) AddRoute ¶ added in v0.10.0
func (r *RouterSink) AddRoute(route Route)
AddRoute adds a new route at runtime, maintaining priority order.
func (*RouterSink) AddRouteGroup ¶ added in v0.10.0
func (r *RouterSink) AddRouteGroup(group RouteGroup)
AddRouteGroup adds all routes from a group to the router at runtime.
func (*RouterSink) CheckHealth ¶ added in v0.10.0
func (r *RouterSink) CheckHealth(ctx context.Context) map[string]HealthStatus
CheckHealth performs health checks on all routes that support it.
func (*RouterSink) Close ¶ added in v0.10.0
func (r *RouterSink) Close() error
Close closes all route sinks and the default sink if present.
func (*RouterSink) Emit ¶ added in v0.10.0
func (r *RouterSink) Emit(event *core.LogEvent)
Emit routes the event according to the configured rules.
func (*RouterSink) GetStats ¶ added in v0.10.0
func (r *RouterSink) GetStats() RouterStats
GetStats returns a copy of the current routing statistics.
func (*RouterSink) PeriodicHealthCheck ¶ added in v0.10.0
func (r *RouterSink) PeriodicHealthCheck(ctx context.Context, interval time.Duration, callback func(map[string]HealthStatus))
PeriodicHealthCheck starts a goroutine that periodically checks sink health.
func (*RouterSink) RemoveRoute ¶ added in v0.10.0
func (r *RouterSink) RemoveRoute(name string) bool
RemoveRoute removes a route by name at runtime.
func (*RouterSink) RemoveRouteGroup ¶ added in v0.10.0
func (r *RouterSink) RemoveRouteGroup(groupName string) int
RemoveRouteGroup removes all routes belonging to a group.
func (*RouterSink) ResetStats ¶ added in v0.10.0
func (r *RouterSink) ResetStats()
ResetStats resets all routing statistics to zero.
type RouterStats ¶ added in v0.10.0
type RouterStats struct {
RouteHits map[string]uint64 // Hit count per route
DefaultHits uint64 // Events sent to default sink
TotalEvents uint64 // Total events processed
DroppedEvents uint64 // Events that matched no routes (no default sink)
}
RouterStats contains routing statistics (safe to copy).
type RoutingMode ¶ added in v0.10.0
type RoutingMode int
RoutingMode determines how the router processes matching routes.
const ( // FirstMatch stops at the first matching route (exclusive routing). FirstMatch RoutingMode = iota // AllMatch sends to all matching routes (broadcast routing). AllMatch )
type SeqOption ¶
type SeqOption func(*SeqSink)
SeqOption configures a Seq sink
func WithSeqAPIKey ¶
WithSeqAPIKey sets the API key for authentication
func WithSeqBatchSize ¶
WithSeqBatchSize sets the batch size
func WithSeqBatchTimeout ¶
WithSeqBatchTimeout sets the batch timeout
func WithSeqCompression ¶
WithSeqCompression enables gzip compression
func WithSeqHTTPClient ¶
WithSeqHTTPClient sets a custom HTTP client
type SeqSink ¶
type SeqSink struct {
// contains filtered or unexported fields
}
SeqSink writes log events to Seq
func NewSeqSink ¶
NewSeqSink creates a new Seq sink
func (*SeqSink) GetMinimumLevel ¶
func (s *SeqSink) GetMinimumLevel() (core.LogEventLevel, error)
GetMinimumLevel queries Seq for the current minimum level by sending a test event and reading the MinimumLevelAccepted from the response
func (*SeqSink) SeqHealthCheck ¶
SeqHealthCheck checks if Seq is healthy
type SplunkOption ¶
type SplunkOption func(*SplunkSink)
SplunkOption configures a Splunk sink
func WithSplunkBatchSize ¶
func WithSplunkBatchSize(size int) SplunkOption
WithSplunkBatchSize sets the batch size
func WithSplunkBatchTimeout ¶
func WithSplunkBatchTimeout(timeout time.Duration) SplunkOption
WithSplunkBatchTimeout sets the batch timeout
func WithSplunkHTTPClient ¶
func WithSplunkHTTPClient(client *http.Client) SplunkOption
WithSplunkHTTPClient sets a custom HTTP client
func WithSplunkHost ¶
func WithSplunkHost(host string) SplunkOption
WithSplunkHost sets the host field
func WithSplunkIndex ¶
func WithSplunkIndex(index string) SplunkOption
WithSplunkIndex sets the Splunk index
func WithSplunkSource ¶
func WithSplunkSource(source string) SplunkOption
WithSplunkSource sets the source field
func WithSplunkSourceType ¶
func WithSplunkSourceType(sourceType string) SplunkOption
WithSplunkSourceType sets the sourcetype field
type SplunkSink ¶
type SplunkSink struct {
// contains filtered or unexported fields
}
SplunkSink writes log events to Splunk HTTP Event Collector (HEC)
func NewSplunkSink ¶
func NewSplunkSink(url, token string, opts ...SplunkOption) (*SplunkSink, error)
NewSplunkSink creates a new Splunk sink
func (*SplunkSink) Emit ¶
func (s *SplunkSink) Emit(event *core.LogEvent)
Emit writes a log event to the sink
type TypedBatchingSink ¶
type TypedBatchingSink[T any] struct { // contains filtered or unexported fields }
TypedBatchingSink batches typed events before emission
func NewTypedBatchingSink ¶
func NewTypedBatchingSink[T any](innerSink TypedSink[T], batchSize int) *TypedBatchingSink[T]
NewTypedBatchingSink creates a new typed batching sink
func (*TypedBatchingSink[T]) Close ¶
func (s *TypedBatchingSink[T]) Close() error
Close flushes and closes the sink
func (*TypedBatchingSink[T]) EmitTyped ¶
func (s *TypedBatchingSink[T]) EmitTyped(event *core.LogEvent, data T) error
EmitTyped adds a typed event to the batch
func (*TypedBatchingSink[T]) Flush ¶
func (s *TypedBatchingSink[T]) Flush() error
Flush sends all batched events
type TypedEvent ¶
TypedEvent combines a log event with typed data