slogx

package
v0.4.21 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigKey       = "config"
	ErrorKey        = "error"
	HealthStatusKey = "health_status"
	PanicKey        = "panic"
	StacktraceKey   = "stacktrace"
	TraceIDKey      = "trace_id"
	SpanIDKey       = "span_id"
	SampledKey      = "sampled"
	SubjectKey      = "subject"
	RPCSystemKey    = "rpc_system"
	RPCServiceKey   = "rpc_service"
	RPCMethodKey    = "rpc_method"

	ResourceIDKey   = "resource_id"
	ResourceNameKey = "resource_name"
)

Keys to use in log attributes.

Variables

This section is empty.

Functions

func Config added in v0.0.94

func Config(conf any) slog.Attr

Config returns the given value with the "config" key.

func Err

func Err(err error) slog.Attr

Err returns a string representation of the error with the "error" key.

func FromContext added in v0.0.90

func FromContext(ctx context.Context) *slog.Logger

FromContext returns the logger from the context, or the default logger if none exists.

func HealthStatus

func HealthStatus(status fmt.Stringer) slog.Attr

HealthStatus returns the given value with the "health_status" key.

func IntoContext added in v0.0.114

func IntoContext(ctx context.Context, logger *slog.Logger) context.Context

IntoContext adds the given logger to the context, returning the new context.

func Panic

func Panic(val any) slog.Attr

Panic returns the given value with the "panic" key.

func RPCMethod

func RPCMethod(method string) slog.Attr

RPCMethod returns the given value with the "rpc_method" key.

func RPCService

func RPCService(service string) slog.Attr

RPCService returns the given value with the "rpc_service" key.

func RPCSystem added in v0.0.90

func RPCSystem(system string) slog.Attr

RPCSystem returns the given value with the "rpc_system" key. It should be used to capture the protocol a RPC request uses, e.g. gRPC, ConnectRPC, etc.

func ResourceID added in v0.3.71

func ResourceID(id fmt.Stringer) slog.Attr

...

func ResourceName added in v0.3.71

func ResourceName(name string) slog.Attr

...

func Sampled added in v0.0.123

func Sampled(span trace.Span) slog.Attr

Sampled returns the sampled status from the given span with the "sampled" key.

func SpanID added in v0.0.123

func SpanID(span trace.Span) slog.Attr

TraceID returns the span ID from the given span with the "span_id" key.

func Stacktrace

func Stacktrace() slog.Attr

Stacktrace returns the current stacktrace with the "stacktrace" key. It should primarily be used during panic recovery.

func Subject added in v0.1.93

func Subject(subject string) slog.Attr

Subject returns the given value with the "subject" key. It should be used to capture the "sub" claim of a JWT.

func TraceID

func TraceID(span trace.Span) slog.Attr

TraceID returns the trace ID from the given span with the "trace_id" key.

Types

This section is empty.

Jump to

Keyboard shortcuts

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