zap icon indicating copy to clipboard operation
zap copied to clipboard

Custom fields in log statement?

Open maros7 opened this issue 4 years ago • 1 comments

Hi, I'm wondering if you'd consider a PR for adding functionality to make it possible to add custom fields to the log statement? E.g. by having something like:

func WithCustomFields(logger *zap.Logger,
	timeFormat string,
	utc bool,
	customFields ...func(c *gin.Context) zap.Field,
) gin.HandlerFunc {

...

Our use-case is that we need to log the return headers.

maros7 avatar Sep 11 '19 15:09 maros7

@maros7 this package https://github.com/things-go/gzap may meet you need.

thinkgos avatar Jun 22 '22 13:06 thinkgos

See https://github.com/gin-contrib/zap#custom-zap-fields

appleboy avatar Sep 15 '22 03:09 appleboy