]> Cypherpunks.ru repositories - gostls13.git/commit
log/slog: empty calls to With and WithGroup are no-ops
authorJonathan Amsterdam <jba@google.com>
Thu, 18 May 2023 13:24:42 +0000 (09:24 -0400)
committerJonathan Amsterdam <jba@google.com>
Mon, 22 May 2023 18:27:07 +0000 (18:27 +0000)
commitbc96901e8959c5eb21d5bca5614eb66481815918
tree6897ccd2017d7ac4bf3f994a6979301911de45e6
parent6d4d71c5abe104d95ede3aa2f3eaaef7bc613ebb
log/slog: empty calls to With and WithGroup are no-ops

It doesn't make sense to call Logger.WithGroup with the empty string.
Make it a no-op by returning the receiver.
This relieves handlers of the burden of detecting that case themselves.

Less importantly, but for consistency, if Logger.With is called with
no args, make it a no-op by returning the receiver.

Along the way, fix obsolete mentions of "the Logger's context" in the
doc.

Change-Id: Ia6caa4f1ca70c1c4b0cab3e222b2fda48be73fef
Reviewed-on: https://go-review.googlesource.com/c/go/+/496175
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
src/log/slog/handler.go
src/log/slog/logger.go