Documentation
¶
Index ¶
- type AKVContext
- type AttributeKeyValuer
- type DurationValuerFunc
- type Handler
- type LevelValuerFunc
- type Option
- func WithDelimiter(delim string) Option
- func WithDurationSecondsValuer() Option
- func WithDurationValuer(f DurationValuerFunc) Option
- func WithLevelValuer(f LevelValuerFunc) Option
- func WithLogEventName(name string) Option
- func WithSource(b bool) Option
- func WithSourceKeyValuer(f SourceKeyValuerFunc) Option
- func WithStringDurationValuer() Option
- func WithTimeRFC3339NanoValuer() Option
- func WithTimeRFC3339Valuer() Option
- func WithTimeUnixNanoValuer() Option
- func WithTimeUnixValuer() Option
- func WithTimeValuer(f TimeValuerFunc) Option
- func WithTraceIDKey(key string) Option
- type SourceKeyValuerFunc
- type TimeValuerFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AKVContext ¶ added in v0.1.7
type AKVContext struct { // Key is the log field key the user used for the value. Key string // HandlerGroup is the list of group set by [slog.Logger.WithGroup]. handlerGroup is nil if the key is not // under any handler group. HandlerGroup []string // ElementGroup is the list of group names that the key is under. // ElementGroup does not include group set by [slog.Logger.WithGroup]. // // `elementGroup` is nil if the key is not // under any group. ElementGroup []string }
type AttributeKeyValuer ¶ added in v0.1.6
type AttributeKeyValuer interface { // AttributeKeyValue returns an OpenTelemetry attribute key and value. // // `key` is the log field key the user used for the value. // // `handlerGroup` is the list of group set by [slog.Logger.WithGroup]. handlerGroup is nil if the key is not // under any handler group. // // `elementGroup` is the list of group names that the key is under. `elementGroup` is nil if the key is not // under any group. AttributeKeyValue(ctx AKVContext) []attribute.KeyValue }
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func NewWithHandler ¶
NewWithHandler returns a new Handler that wraps the given handler.
func (*Handler) Enabled ¶
Enabled implements the slog.Handler interface.
func (*Handler) Handle ¶
Handle implements the slog.Handler interface.
func (*Handler) WithAttrs ¶
WithAttrs implements the slog.Handler interface.
func (*Handler) WithGroup ¶
WithGroup implements the slog.Handler interface.
WithGroup adds prefix to the event name, NOT the log elements themselves when they are added to the span.
Group attribute for log elements will be added to the span as is.
Does not effect how the wrapped handler handles the log elements.
type Option ¶
type Option func(h *Handler)
func WithDelimiter ¶ added in v0.1.6
WithDelimiter sets the delimiter to use when joining the log group.
func WithDurationSecondsValuer ¶
func WithDurationSecondsValuer() Option
WithDurationSecondsValuer sets duration types to be formatted as seconds when being set as span's log event attribute.
func WithDurationValuer ¶
func WithDurationValuer(f DurationValuerFunc) Option
WithDurationValuer sets how the duration is formatted when being set as span attribute.
Use this option if you want to use a custom duration format and none of the provided duration valuer suits your needs.
func WithLevelValuer ¶ added in v0.1.2
func WithLevelValuer(f LevelValuerFunc) Option
WithLevelValuer extracts the log level and set it as event attribute.
func WithLogEventName ¶
WithLogEventName sets the name of the log event attribute. Default is "log".
func WithSource ¶ added in v0.1.2
WithSource enables the extraction of the caller location and set it as event attribute.
For formatting the output, see WithSourceKeyValuer.
func WithSourceKeyValuer ¶ added in v0.1.2
func WithSourceKeyValuer(f SourceKeyValuerFunc) Option
WithSourceKeyValuer extracts the caller location and set it as event attribute.
func WithStringDurationValuer ¶
func WithStringDurationValuer() Option
WithStringDurationValuer sets duration types to be formatted as string when being set as span's log event attribute.
func WithTimeRFC3339NanoValuer ¶
func WithTimeRFC3339NanoValuer() Option
WithTimeRFC3339NanoValuer sets time types to be formatted as RFC3339Nano when being set as span attribute.
func WithTimeRFC3339Valuer ¶
func WithTimeRFC3339Valuer() Option
WithTimeRFC3339Valuer sets time types to be formatted as RFC3339 when being set as span attribute.
func WithTimeUnixNanoValuer ¶
func WithTimeUnixNanoValuer() Option
WithTimeUnixNanoValuer sets time types to be formatted as Unix Nano Seconds when being set as span attribute.
func WithTimeUnixValuer ¶
func WithTimeUnixValuer() Option
WithTimeUnixValuer sets time types to be formatted as Unix Seconds when being set as span attribute.
func WithTimeValuer ¶
func WithTimeValuer(f TimeValuerFunc) Option
WithTimeValuer sets how the time is formatted when being set as span's log event attribute.
Use this option if you want to use a custom time format and none of the provided time formatters suits your needs.
func WithTraceIDKey ¶ added in v0.1.1
WithTraceIDKey sets the key of the trace ID attribute to include in logs. Default is "trace_id".