aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Amsterdam <jba@google.com>2025-06-08 08:49:25 -0400
committerGopher Robot <gobot@golang.org>2025-06-09 09:04:58 -0700
commit7800f4f0adbc749be95d13be48524e9702c50bbc (patch)
tree8c42fb70c28176300e4784faace057533603b7d0
parentd184f8dc020ac635cea02c046ab1d0b87dfd624d (diff)
downloadgo-7800f4f0adbc749be95d13be48524e9702c50bbc.tar.xz
log/slog: fix level doc on handlers
Fixed doc on {JSON,Text}Handler.Handle: the level is never omitted. Fixes #73943. Change-Id: Ia470cbe5d713ab18dd80eeea1c0ab8f5e6d30f3f Reviewed-on: https://go-review.googlesource.com/c/go/+/680055 Auto-Submit: Jonathan Amsterdam <jba@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com> Reviewed-by: Sean Liao <sean@liao.dev>
-rw-r--r--src/log/slog/json_handler.go4
-rw-r--r--src/log/slog/text_handler.go4
2 files changed, 2 insertions, 6 deletions
diff --git a/src/log/slog/json_handler.go b/src/log/slog/json_handler.go
index da3eae1a8e..f139c54139 100644
--- a/src/log/slog/json_handler.go
+++ b/src/log/slog/json_handler.go
@@ -63,9 +63,7 @@ func (h *JSONHandler) WithGroup(name string) Handler {
// Otherwise, the key is "time"
// and the value is output as with json.Marshal.
//
-// If the Record's level is zero, the level is omitted.
-// Otherwise, the key is "level"
-// and the value of [Level.String] is output.
+// The level's key is "level" and its value is the result of calling [Level.String].
//
// If the AddSource option is set and source information is available,
// the key is "source", and the value is a record of type [Source].
diff --git a/src/log/slog/text_handler.go b/src/log/slog/text_handler.go
index 6819e633bb..5a0d0a4a7e 100644
--- a/src/log/slog/text_handler.go
+++ b/src/log/slog/text_handler.go
@@ -62,9 +62,7 @@ func (h *TextHandler) WithGroup(name string) Handler {
// Otherwise, the key is "time"
// and the value is output in RFC3339 format with millisecond precision.
//
-// If the Record's level is zero, the level is omitted.
-// Otherwise, the key is "level"
-// and the value of [Level.String] is output.
+// The level's key is "level" and its value is the result of calling [Level.String].
//
// If the AddSource option is set and source information is available,
// the key is "source" and the value is output as FILE:LINE.