-
Notifications
You must be signed in to change notification settings - Fork 77
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
call stack skipping #30
Comments
Some potential solutions:
|
I personally like Performance might be a concern. However, the struct that for example klogr needs to copy isn't big: https://github.com/uber-go/zap/blob/master/options.go#L108 (link from the extended klogr with two different output formats in PR kubernetes/klog#197). I don't feel too strongly about it, though. I'm also fine with |
I acknowledge why this is useful. Not every implementation logs line numbers, but it's common enough that this matters, IMO. Whatever we do here, implementations that don't log line numbers can just ignore this. Adding methods is somewhat ugly. I instinctively lean away from a number-of-methods multiplier like this. We star with Info/Error. Then we add InfoDepth/ErrorDepth. Then at some future point we justify something else optional, and we end up with Info, Error, InfoDepth, ErrorDepth, InfoFoo, ErrorFoo, InfoDepthFoo, ErrorDepthFoo. Adding args to methods is a breaking change, so pretty much off the table. Adding some sort of options pattern seems best. I spent some time thinking about it and I don't see a cleaner answer than something like:
The name is open for debate, of course. Thoughts? |
PRs proposed |
That was also my thinking.
I'm fine with that. |
klogr implementation of WithCallDepth in https://github.com/pohly/klog/commits/klogr-call-depth |
When wrapping a logr instance with some additional helper functions, it may be necessary to inform the wrapped instance that it has to skip additional levels in the call stack to find the actual source code location for the log message.
The text was updated successfully, but these errors were encountered: