sirupsen / logrus

Structured, pluggable logging for Go.
MIT License
24.76k stars 2.27k forks source link

Easy way to %+v format a struct? #1351

Closed znd4 closed 2 years ago

znd4 commented 2 years ago

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?

Thanks, Zane

github-actions[bot] commented 2 years ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 2 years ago

This issue was closed because it has been inactive for 14 days since being marked as stale.