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

Add Any field function for any value #514

Closed
dils2k opened this issue Jan 7, 2023 · 1 comment · Fixed by #515
Closed

Add Any field function for any value #514

dils2k opened this issue Jan 7, 2023 · 1 comment · Fixed by #515

Comments

@dils2k
Copy link
Contributor

dils2k commented Jan 7, 2023

Go introduced any type, that is just an empty interface under the hood. I think it would be good to introduce Any() function in zerolog as well. Under the hood it will use the old Interface() function.

Example:

// before
log.Debug().Interface("params", p).Msg("charge request")

// after
log.Debug().Any("params", p).Msg("charge request")

It makes the line a bit shorter and, in my opinion, makes it more obvious of what it's going to log.

Also I don't propose to removeInterface() function, I propose to add a new function that's going to do the same thing that the old function did.

@kevinmichaelchen
Copy link

@rs Thanks for the addition! Can we cut a new tag?

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

Successfully merging a pull request may close this issue.

2 participants