mozilla-services / autograph

Mozilla's digital signature service
https://hub.docker.com/r/mozilla/autograph/
Mozilla Public License 2.0
151 stars 35 forks source link

DRY up signature request log.Fields #786

Open g-k opened 2 years ago

g-k commented 2 years ago

nit: Seeing this set of fields in a number of locations, I wonder if this should be moved to a struct that can output a log.Fields.

_Originally posted by @ajvb in https://github.com/mozilla-services/autograph/pull/782#discussion_r723572719_

g-k commented 2 years ago

An alternative or additional option, https://github.com/mozilla-services/autograph/pull/782#discussion_r723599970

The logrus readme includes this example:

  // A common pattern is to re-use fields between logging statements by re-using
  // the logrus.Entry returned from WithFields()
  contextLogger := log.WithFields(log.Fields{
    "common": "this is a common field",
    "other": "I also should be logged always",
  })

so that might be an option too. Unless you think it should be addressed in this PR I'll take a TODO and file an issue to clean that up.

g-k commented 2 years ago

This would dedupe some code and standardize the logs a bit more.