Documentation
¶
Index ¶
- Constants
- func CommonEnvironmentEnrichers() []core.LogEventEnricher
- func WithCorrelationId(ctx context.Context, correlationId string) context.Context
- func WithRequestId(ctx context.Context, requestId string) context.Context
- func WithSessionId(ctx context.Context, sessionId string) context.Context
- func WithUserId(ctx context.Context, userId interface{}) context.Context
- type CallersEnricher
- type ContextEnricher
- type ContextValueEnricher
- type CorrelationIdEnricher
- type EnvironmentEnricher
- type MachineNameEnricher
- type ProcessEnricher
- type SourceContextEnricher
- type ThreadIdEnricher
- type ThreadLocalCorrelationIdEnricher
- type TimestampEnricher
Constants ¶
const ( // CorrelationIdKey is the context key for correlation IDs. CorrelationIdKey contextKey = "correlationId" // RequestIdKey is the context key for request IDs. RequestIdKey contextKey = "requestId" // UserIdKey is the context key for user IDs. UserIdKey contextKey = "userId" // SessionIdKey is the context key for session IDs. SessionIdKey contextKey = "sessionId" )
Variables ¶
This section is empty.
Functions ¶
func CommonEnvironmentEnrichers ¶
func CommonEnvironmentEnrichers() []core.LogEventEnricher
CommonEnvironmentEnrichers returns enrichers for common environment variables.
func WithCorrelationId ¶
WithCorrelationId returns a context with a correlation ID.
func WithRequestId ¶
WithRequestId returns a context with a request ID.
func WithSessionId ¶
WithSessionId returns a context with a session ID.
Types ¶
type CallersEnricher ¶
type CallersEnricher struct {
// contains filtered or unexported fields
}
CallersEnricher adds caller information to log events.
func NewCallersEnricher ¶
func NewCallersEnricher(skip int) *CallersEnricher
NewCallersEnricher creates an enricher that adds caller information. skip determines how many stack frames to skip (default should be 6-7 for most logger implementations).
func (*CallersEnricher) Enrich ¶
func (c *CallersEnricher) Enrich(event *core.LogEvent, propertyFactory core.LogEventPropertyFactory)
Enrich adds caller information to the log event.
type ContextEnricher ¶
type ContextEnricher struct {
// contains filtered or unexported fields
}
ContextEnricher enriches log events with values from context.Context.
func NewContextEnricher ¶
func NewContextEnricher(ctx context.Context) *ContextEnricher
NewContextEnricher creates an enricher that extracts values from the given context.
func NewContextEnricherWithKeys ¶
func NewContextEnricherWithKeys(ctx context.Context, propertyKeys map[contextKey]string) *ContextEnricher
NewContextEnricherWithKeys creates an enricher with custom context key mappings.
func (*ContextEnricher) Enrich ¶
func (c *ContextEnricher) Enrich(event *core.LogEvent, propertyFactory core.LogEventPropertyFactory)
Enrich adds context values to the log event.
type ContextValueEnricher ¶
type ContextValueEnricher struct {
// contains filtered or unexported fields
}
ContextValueEnricher enriches log events with a specific value from context.
func NewContextValueEnricher ¶
func NewContextValueEnricher(ctx context.Context, key interface{}, propertyName string) *ContextValueEnricher
NewContextValueEnricher creates an enricher for a specific context value.
func (*ContextValueEnricher) Enrich ¶
func (c *ContextValueEnricher) Enrich(event *core.LogEvent, propertyFactory core.LogEventPropertyFactory)
Enrich adds the context value to the log event.
type CorrelationIdEnricher ¶
type CorrelationIdEnricher struct {
// contains filtered or unexported fields
}
CorrelationIdEnricher adds a correlation ID to all log events. This is useful for tracing requests across multiple services.
func NewCorrelationIdEnricher ¶
func NewCorrelationIdEnricher(correlationId string) *CorrelationIdEnricher
NewCorrelationIdEnricher creates an enricher with a specific correlation ID.
func (*CorrelationIdEnricher) Enrich ¶
func (c *CorrelationIdEnricher) Enrich(event *core.LogEvent, propertyFactory core.LogEventPropertyFactory)
Enrich adds the correlation ID to the log event.
type EnvironmentEnricher ¶
type EnvironmentEnricher struct {
// contains filtered or unexported fields
}
EnvironmentEnricher adds environment variable values to log events.
func NewEnvironmentEnricher ¶
func NewEnvironmentEnricher(variableName, propertyName string) *EnvironmentEnricher
NewEnvironmentEnricher creates an enricher that adds the value of an environment variable.
func NewEnvironmentEnricherCached ¶
func NewEnvironmentEnricherCached(variableName, propertyName string) *EnvironmentEnricher
NewEnvironmentEnricherCached creates an enricher that caches the environment variable value.
func (*EnvironmentEnricher) Enrich ¶
func (e *EnvironmentEnricher) Enrich(event *core.LogEvent, propertyFactory core.LogEventPropertyFactory)
Enrich adds the environment variable value to the log event.
type MachineNameEnricher ¶
type MachineNameEnricher struct {
// contains filtered or unexported fields
}
MachineNameEnricher adds the machine name to log events.
func NewMachineNameEnricher ¶
func NewMachineNameEnricher() *MachineNameEnricher
NewMachineNameEnricher creates a new machine name enricher.
func NewMachineNameEnricherWithName ¶
func NewMachineNameEnricherWithName(propertyName string) *MachineNameEnricher
NewMachineNameEnricherWithName creates a new machine name enricher with a custom property name.
func (*MachineNameEnricher) Enrich ¶
func (me *MachineNameEnricher) Enrich(event *core.LogEvent, propertyFactory core.LogEventPropertyFactory)
Enrich adds the machine name to the log event.
type ProcessEnricher ¶
type ProcessEnricher struct {
// contains filtered or unexported fields
}
ProcessEnricher adds process information to log events.
func NewProcessEnricher ¶
func NewProcessEnricher() *ProcessEnricher
NewProcessEnricher creates a new process enricher.
func (*ProcessEnricher) Enrich ¶
func (pe *ProcessEnricher) Enrich(event *core.LogEvent, propertyFactory core.LogEventPropertyFactory)
Enrich adds process information to the log event.
type SourceContextEnricher ¶ added in v0.2.0
type SourceContextEnricher struct {
// contains filtered or unexported fields
}
SourceContextEnricher adds the source context (logger name/type) to log events.
func ForSourceContext ¶ added in v0.2.0
func ForSourceContext(sourceContext string) *SourceContextEnricher
ForSourceContext creates a new enricher with the specified source context. This is useful for creating sub-loggers with specific contexts.
func NewAutoSourceContextEnricher ¶ added in v0.2.0
func NewAutoSourceContextEnricher() *SourceContextEnricher
NewAutoSourceContextEnricher creates an enricher that automatically detects the source context.
func NewSourceContextEnricher ¶ added in v0.2.0
func NewSourceContextEnricher(sourceContext string) *SourceContextEnricher
NewSourceContextEnricher creates an enricher that adds the specified source context.
func (*SourceContextEnricher) Enrich ¶ added in v0.2.0
func (e *SourceContextEnricher) Enrich(event *core.LogEvent, propertyFactory core.LogEventPropertyFactory)
Enrich adds the source context to the log event.
type ThreadIdEnricher ¶
type ThreadIdEnricher struct{}
ThreadIdEnricher adds the current goroutine ID to log events. Note: Go doesn't expose goroutine IDs officially, so this uses a workaround.
func NewThreadIdEnricher ¶
func NewThreadIdEnricher() *ThreadIdEnricher
NewThreadIdEnricher creates a new thread ID enricher.
func (*ThreadIdEnricher) Enrich ¶
func (t *ThreadIdEnricher) Enrich(event *core.LogEvent, propertyFactory core.LogEventPropertyFactory)
Enrich adds the goroutine ID to the log event.
type ThreadLocalCorrelationIdEnricher ¶
type ThreadLocalCorrelationIdEnricher struct {
// contains filtered or unexported fields
}
ThreadLocalCorrelationIdEnricher uses goroutine-local storage for correlation IDs. Note: This is a simplified implementation. In production, you might want to use a proper goroutine-local storage library or pass correlation IDs explicitly.
func NewThreadLocalCorrelationIdEnricher ¶
func NewThreadLocalCorrelationIdEnricher() *ThreadLocalCorrelationIdEnricher
NewThreadLocalCorrelationIdEnricher creates a new thread-local correlation ID enricher.
func (*ThreadLocalCorrelationIdEnricher) ClearCorrelationId ¶
func (t *ThreadLocalCorrelationIdEnricher) ClearCorrelationId()
ClearCorrelationId clears the correlation ID for the current goroutine.
func (*ThreadLocalCorrelationIdEnricher) Enrich ¶
func (t *ThreadLocalCorrelationIdEnricher) Enrich(event *core.LogEvent, propertyFactory core.LogEventPropertyFactory)
Enrich adds the correlation ID for the current goroutine to the log event.
func (*ThreadLocalCorrelationIdEnricher) SetCorrelationId ¶
func (t *ThreadLocalCorrelationIdEnricher) SetCorrelationId(correlationId string)
SetCorrelationId sets the correlation ID for the current goroutine.
type TimestampEnricher ¶
type TimestampEnricher struct {
// contains filtered or unexported fields
}
TimestampEnricher adds a high-precision timestamp to log events.
func NewTimestampEnricher ¶
func NewTimestampEnricher() *TimestampEnricher
NewTimestampEnricher creates a new timestamp enricher.
func NewTimestampEnricherWithName ¶
func NewTimestampEnricherWithName(propertyName string) *TimestampEnricher
NewTimestampEnricherWithName creates a new timestamp enricher with a custom property name.
func (*TimestampEnricher) Enrich ¶
func (te *TimestampEnricher) Enrich(event *core.LogEvent, propertyFactory core.LogEventPropertyFactory)
Enrich adds the current timestamp to the log event.