Skip to content

Commit 1cb70ba

Browse files
authored
feat(v2): update WithLogger to WithLoggerContext. (#478)
1 parent f53618c commit 1cb70ba

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

v2/callctx/callctx.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ type loggerContextKey string
132132

133133
const loggerCKey = loggerContextKey("logger")
134134

135-
// WithLogger injects a slog.Logger into the context. This logger will be
136-
// extracted by the client library or transport wrappers to emit logs.
137-
func WithLogger(ctx context.Context, logger *slog.Logger) context.Context {
135+
// WithLoggerContext injects a slog.Logger into the context. This logger will
136+
// be extracted by the client library or transport wrappers to emit logs.
137+
func WithLoggerContext(ctx context.Context, logger *slog.Logger) context.Context {
138138
return context.WithValue(ctx, loggerCKey, logger)
139139
}
140140

v2/callctx/callctx_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ func TestLoggerFromContext(t *testing.T) {
137137
// Should extract the exact logger that was injected
138138
var logOutput bytes.Buffer
139139
injectedLogger := slog.New(slog.NewTextHandler(&logOutput, nil))
140-
ctx = WithLogger(ctx, injectedLogger)
140+
ctx = WithLoggerContext(ctx, injectedLogger)
141141

142142
extractedLogger, ok := LoggerFromContext(ctx)
143143
if !ok || extractedLogger != injectedLogger {

0 commit comments

Comments
 (0)