Skip to content

Commit 6a41f9d

Browse files
committed
Revert "Make SinkContext a struct"
It's better as an interface so users don't have to call the `Sink` method on the struct during Make. - Move SinkContext into context.go
1 parent 95bc0f1 commit 6a41f9d

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

context.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,21 @@ import "context"
44

55
type loggerCtxKey = struct{}
66

7-
// SinkContext is used by slog.Make to compose many loggers together.
8-
type SinkContext struct {
7+
type sinkContext struct {
8+
context.Context
9+
Sink
10+
}
11+
12+
// SinkContext is a context that implements Sink.
13+
// It may be returned by log creators to allow for composition.
14+
type SinkContext interface {
915
Sink
1016
context.Context
1117
}
1218

1319
func contextWithLogger(ctx context.Context, l logger) SinkContext {
1420
ctx = context.WithValue(ctx, loggerCtxKey{}, l)
15-
return SinkContext{
21+
return &sinkContext{
1622
Context: ctx,
1723
Sink: l,
1824
}

0 commit comments

Comments
 (0)