aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Amsterdam <jba@google.com>2023-05-09 16:22:09 -0400
committerJonathan Amsterdam <jba@google.com>2023-05-10 11:51:03 +0000
commita3efb96aafc2e8d8a7c7bfc673d59158b692c355 (patch)
tree258091d42813876d95ed1f37918741f8a5bfe56b
parent2ca4104f0519027c55266d48b47ea16ee4da6915 (diff)
downloadgo-a3efb96aafc2e8d8a7c7bfc673d59158b692c355.tar.xz
log/slog: add json struct tags to Source
Add tags to the fields of Source that lower-cases their names for JSON. The implementation still treats Source specially for performance, but now the result would be identical if it did not. Change-Id: I5fd2e500f1a301db62af87be8b877ecd954a26ec Reviewed-on: https://go-review.googlesource.com/c/go/+/494035 Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Alan Donovan <adonovan@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
-rw-r--r--src/log/slog/record.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/log/slog/record.go b/src/log/slog/record.go
index d77a6eddca..77dcc477fd 100644
--- a/src/log/slog/record.go
+++ b/src/log/slog/record.go
@@ -166,11 +166,11 @@ type Source struct {
// Function is the package path-qualified function name containing the
// source line. If non-empty, this string uniquely identifies a single
// function in the program. This may be the empty string if not known.
- Function string
+ Function string `json:"function"`
// File and Line are the file name and line number (1-based) of the source
// line. These may be the empty string and zero, respectively, if not known.
- File string
- Line int
+ File string `json:"file"`
+ Line int `json:"line"`
}
// attrs returns the non-zero fields of s as a slice of attrs.