Skip to content

Commit e88ff39

Browse files
authored
Merge pull request #86 from cdr/sink-context-iface
Sink context iface
2 parents 95bc0f1 + 6a41f9d commit e88ff39

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)