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

Would like negative version of AddCaller #702

Closed
danielbprice opened this issue Apr 24, 2019 · 3 comments · Fixed by #806
Closed

Would like negative version of AddCaller #702

danielbprice opened this issue Apr 24, 2019 · 3 comments · Fixed by #806

Comments

@danielbprice
Copy link
Contributor

danielbprice commented Apr 24, 2019

If I have a logger and I need to derive a child logger which has the caller disabled, there doesn't seem to be a way to do it.

I had hoped to do something like:

child := parent.WithOptions(zap.DisableCaller())
@abhinav
Copy link
Collaborator

abhinav commented Apr 25, 2019

This seems like a reasonable ask.

My preference would have been for AddCaller() to accept a boolean argument
rather than being a switch in one direction.

zap.AddCaller(true)
zap.AddCaller(false)

Unfortunately, it's too late to change that API so adding a new option makes
sense.

As for the name, I would prefer AddCallerDisable because of godoc
discoverability (it'll show up next to AddCaller and AddCallerSkip) but I'd
like to hear what others think about this.

CC @jcorbin @prashantv

@prashantv
Copy link
Collaborator

Seems reasonable to add an option to disable it (we may want to same thing for other similar options like Development).

As a short-term workaround, I think you can achieve this using WrapCore to return a core that just drops the Caller field in Entry before passing it through to the original core.

@danielbprice
Copy link
Contributor Author

I have no real stake in the name-- except to say that, for discoverability-- I had assumed there would be such an option after discovering DisableCaller in the Config struct ( https://github.com/uber-go/zap/blob/master/config.go )

danielbprice added a commit to danielbprice/zap that referenced this issue Mar 26, 2020
danielbprice added a commit to danielbprice/zap that referenced this issue Mar 26, 2020
danielbprice added a commit to danielbprice/zap that referenced this issue Apr 3, 2020
danielbprice added a commit to danielbprice/zap that referenced this issue Apr 3, 2020
danielbprice added a commit to danielbprice/zap that referenced this issue Apr 11, 2020
prashantv pushed a commit that referenced this issue Apr 15, 2020
uvfive pushed a commit to bxsmart/zap that referenced this issue May 21, 2020
cgxxv pushed a commit to cgxxv/zap that referenced this issue Mar 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants