MCPcopy Create free account
hub / github.com/coder/slog / Stdlib

Function Stdlib

s.go:18–30  ·  view source on GitHub ↗

Stdlib creates a standard library logger from the given logger. All logs will be logged at the level set by the logger and the given ctx will be passed to the logger's Log method, thereby logging all fields and tracing info in the context. You can redirect the stdlib default logger with log.SetOut

(ctx context.Context, l Logger, level Level)

Source from the content-addressed store, hash-verified

16// to the Writer on the logger returned by this function.
17// See the example.
18func Stdlib(ctx context.Context, l Logger, level Level) *log.Logger {
19 l.skip += 2
20
21 l = l.Named("stdlib")
22
23 w := &stdlogWriter{
24 ctx: ctx,
25 l: l,
26 level: level,
27 }
28
29 return log.New(w, "", 0)
30}
31
32type stdlogWriter struct {
33 ctx context.Context

Callers

nothing calls this directly

Calls 1

NamedMethod · 0.80

Tested by

no test coverage detected