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

AddCaller() with JSON output #157

Closed
maticmeznar opened this issue Oct 19, 2016 · 3 comments
Closed

AddCaller() with JSON output #157

maticmeznar opened this issue Oct 19, 2016 · 3 comments

Comments

@maticmeznar
Copy link

I used to be able to use AddCaller() with JSON output, but since updating Zap, I cannot. Is it ever going to be added back? If yes, when? If no, whats the last version of Zap where it still worked?

Error:
cannot use zap.AddCaller() (type zap.Option) as type zap.JSONOption in argument to zap.NewJSONEncoder

@jdknezek
Copy link

jdknezek commented Nov 4, 2016

I think the issue is that AddCaller() is an Option for a Logger, whereas you're trying to add it as a JSONOption to a JSONEncoder. You should change:

logger := zap.New(zap.NewJSONEncoder(zap.AddCaller()))

to

logger := zap.New(zap.NewJSONEncoder(), zap.AddCaller())

@akshayjshah
Copy link
Contributor

@jdknezek is correct - AddCaller is an option for the logger, not the encoder. Be aware that AddCaller is a bit broken at the moment, and may be removed in the future (see #40).

@maticmeznar
Copy link
Author

My bad, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants