rs / zerolog

Zero Allocation JSON Logger
MIT License
10.62k stars 572 forks source link

Add Any field function for any value #514

Closed dils2k closed 1 year ago

dils2k commented 1 year ago

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 commented 1 year ago

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