You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think you should add a skip caller option to the HandlerOptions struct{} to prevent a call in the first path. For example, Zap has a method named zap.AddCallerSkip(1) to prevent a call in the first path.
The text was updated successfully, but these errors were encountered:
Ja7ad
changed the title
log/slog: skip caller of add source
log/slog: skip caller for add source
Oct 1, 2023
seankhliao
changed the title
log/slog: skip caller for add source
proposal: log/slog: skip caller for add source
Oct 1, 2023
Based on my observation, this proposal seems to be the same as #59145.
The idea has been declined in the past.
I believe it would be a mistake to tie the call depth into the logger as a WithCallDepth method implies. More generally we went through the whole problem with WithContext of trying to provide a fluent API, and we walked away from that. I think we would need a very good reason to go back to fluent-style APIs. Let's focus on solutions that don't overload Logger with extra state.
As per the recommendation of @jba, it is feasible to write while using the following guidelines.
Based on my observation, this proposal seems to be the same as #59145.
The idea has been declined in the past.
I believe it would be a mistake to tie the call depth into the logger as a WithCallDepth method implies. More generally we went through the whole problem with WithContext of trying to provide a fluent API, and we walked away from that. I think we would need a very good reason to go back to fluent-style APIs. Let's focus on solutions that don't overload Logger with extra state.
As per the recommendation of @jba, it is feasible to write while using the following guidelines.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I wrap slog methods for send specific log with custom feature.
for example :
What did you expect to see?
But
AddSource
send call function line 163 inlogger.go
,If you have to send called line inlogger_test.go
.Output:
time=2023-10-01T09:18:06.586+03:30 level=ERROR source=/home/javad/go/src/microservice/logger/logger.go:163 msg="error example" test=2
What did you see instead?
I think you should add a skip caller option to the
HandlerOptions struct{}
to prevent a call in the first path. For example, Zap has a method namedzap.AddCallerSkip(1)
to prevent a call in the first path.The text was updated successfully, but these errors were encountered: