Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log/slog: JSONHandler does not format the source attribute in conformance with its documentation #60329

Closed
komuw opened this issue May 21, 2023 · 3 comments
Labels
Documentation NeedsFix The path to resolution is known, but the work has not been done.

Comments

@komuw
Copy link
Contributor

komuw commented May 21, 2023

What version of Go are you using (go version)?

$ go version
go version go1.20.4 linux/amd64

Does this issue reproduce with the latest release?

Yes

gotip version
  go version devel go1.21-b950cc8f11 Sat May 20 21:53:52 2023 +0000 linux/amd64

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/komuw/.cache/go-build'
GOENV='/home/komuw/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/komuw/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/komuw/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/komuw/sdk/gotip'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLDIR='/home/komuw/sdk/gotip/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='devel go1.21-b950cc8f11 Sat May 20 21:53:52 2023 +0000'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/komuw/Downloads/cool/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/run/user/1000/go-build3180755045=/tmp/go-build -gno-record-gcc-switches'

What did you do?

Run the program; https://go.dev/play/p/YVBdftehuQ7

What did you expect to see?

{"time":"2023-05-21T17:12:19.865170422+03:00","level":"INFO","source":"/home/cool/main.go:15",,"msg":"hey"}

What did you see instead?

{"time":"2023-05-21T17:12:19.865170422+03:00","level":"INFO","source":{"function":"main.main","file":"/home/cool/main.go","line":15},"msg":"hey"}

The docs;

// If the AddSource option is set and source information is available,
// the key is "source"
// and the value is output as "FILE:LINE".
say; If the AddSource option is set and source information is available, the key is "source" and the value is output as "FILE:LINE".

@komuw
Copy link
Contributor Author

komuw commented May 21, 2023

Gopherbot has added the Documentation label, but I think it is not a documentation issue; at least not strictly.
It is the code that should be updated to match the documentation, we could also do it the other way, but I think the former is better.

cc @jba

@seankhliao
Copy link
Member

I think it was decided that the current encoding is correct and it's just a documentation issue
#59345 (comment)

@seankhliao seankhliao added the NeedsFix The path to resolution is known, but the work has not been done. label May 21, 2023
@gopherbot
Copy link

Change https://go.dev/cl/496815 mentions this issue: log/slog: JSONHandler doesn't use special source format

eric pushed a commit to fancybits/go that referenced this issue Sep 7, 2023
Fixes golang#60329

Change-Id: Idb19da4830fa14c459bedbf143d550ce7c1dfdbd
Reviewed-on: https://go-review.googlesource.com/c/go/+/496815
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
eric pushed a commit to fancybits/go that referenced this issue Sep 7, 2023
Fixes golang#60329

Change-Id: Idb19da4830fa14c459bedbf143d550ce7c1dfdbd
Reviewed-on: https://go-review.googlesource.com/c/go/+/496815
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants