Hi y'all, is there a simple way to "automatically" format structs with %+v when they're passed in as fields?
I know I can
logger.Infof("pet: %+v", petInstance)
but it'd be nice to be able include it as a field and include my struct's field names without having to add a fmt.Sprintf call each place I pass in a field.
My guess is that I could do it with a hook, or with CallerPrettyfier in the json formatter, but it seems kind of hazy to me.
If I do end up figuring this out, could I add a small section to the Tips page in the wiki?
Hi y'all, is there a simple way to "automatically" format structs with
%+v
when they're passed in as fields?I know I can
but it'd be nice to be able include it as a field and include my struct's field names without having to add a
fmt.Sprintf
call each place I pass in a field.My guess is that I could do it with a hook, or with
CallerPrettyfier
in the json formatter, but it seems kind of hazy to me.If I do end up figuring this out, could I add a small section to the Tips page in the wiki?
Thanks, Zane