Skip to content

ertia-io/slogx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

slogx

Attach a slog.Logger to a context

logger := slog.New(slog.NewTextHandler(os.Stderr, nil))

// Attach
ctx := slogx.WithContext(context.Background(), logger)

// Retrieve
log := slogx.Ctx(ctx)

// Attach attributes to logger inside context
ctx = slogx.With(ctx, "key", "value")

log.Info("Hello world")

About

Attach a slog.Logger to a context

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages