slog

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: Apache-2.0 Imports: 4 Imported by: 2 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package slog bridges standard library slog handlers to telemetry.Logger.

A common integration pattern is to use a scoped logger:

libScope := scope.Register("mylib", "mylib's slog messages")
myLib.SetLoggingDefault(slog.New(bridgedslog.NewHandlerWithCallerSkipDelta(libScope, 4)))

NewHandler uses a default caller skip delta of 3. If your slog integration adds extra wrapper frames, use NewHandlerWithCallerSkipDelta to override it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

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

Handler forwards slog records to a telemetry.Logger.

func NewHandler

func NewHandler(logger telemetry.Logger) *Handler

NewHandler creates a slog.Handler backed by telemetry.Logger.

func NewHandlerWithCallerSkipDelta added in v0.4.1

func NewHandlerWithCallerSkipDelta(logger telemetry.Logger, callerSkipDelta int) *Handler

NewHandlerWithCallerSkipDelta creates a slog.Handler backed by telemetry.Logger and applies the provided caller skip delta when the logger supports caller skipping.

func (*Handler) Enabled

func (h *Handler) Enabled(_ context.Context, level stdslog.Level) bool

Enabled reports whether the telemetry logger should emit this slog level.

func (*Handler) Handle

func (h *Handler) Handle(ctx context.Context, record stdslog.Record) error

Handle forwards the record to the matching telemetry logging method.

func (*Handler) WithAttrs

func (h *Handler) WithAttrs(attrs []stdslog.Attr) stdslog.Handler

WithAttrs returns a handler that includes the provided attributes.

func (*Handler) WithGroup

func (h *Handler) WithGroup(name string) stdslog.Handler

WithGroup returns a handler with an extra attribute group prefix.

Jump to

Keyboard shortcuts

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