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

x/exp/slog: Customising log source value #63811

Closed
bentcoder opened this issue Oct 29, 2023 · 1 comment
Closed

x/exp/slog: Customising log source value #63811

bentcoder opened this issue Oct 29, 2023 · 1 comment
Labels
Milestone

Comments

@bentcoder
Copy link

Hi,

RE: #59280 (comment)

func (s *Source) String() string { return fmt.Sprintf("%s:%d", s.File, s.Line) }

What @rsc suggested above is what all our app's are doing for many years. I am wondering if I can somehow accomplish the same behaviour using Slog?

If there is still possibility for a simple string value, I will then get rid of working directory from it (file) and have a final value as shown below.

"source": "/Users/myself/dev/tetris/cmd/api/main.go:15" <--- FROM
"source": "/cmd/api/main.go:15"                         <--- TO

Note: I am coming from Zerolog and Logrus background and both have this possibility but I am not sure if Slog has it. If id does, I prefer migrating to Slog.

Thank you

CC: @jba

@gopherbot gopherbot added this to the Unreleased milestone Oct 29, 2023
@seankhliao
Copy link
Member

see slog.SouceKey and slog.Record.PC

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Oct 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants