refactor(server): Use logrus convenience functions for logs

Makes use of the `.WithError` and `.WithField` convenience functions
in logrus to simplify log statement construction.

This has the added benefit of making it easier to correctly log
errors.
This commit is contained in:
Vincent Ambo 2019-10-06 14:48:24 +01:00 committed by Vincent Ambo
parent c1020754a2
commit d7ffbbdea4
5 changed files with 59 additions and 128 deletions

View file

@ -36,16 +36,11 @@ func signingOptsFromEnv() *storage.SignedURLOptions {
return nil
}
log.WithFields(log.Fields{
"account": id,
}).Info("GCS URL signing enabled")
log.WithField("account", id).Info("GCS URL signing enabled")
k, err := ioutil.ReadFile(path)
if err != nil {
log.WithFields(log.Fields{
"file": path,
"error": err,
}).Fatal("failed to read GCS signing key")
log.WithError(err).WithField("file", path).Fatal("failed to read GCS signing key")
}
return &storage.SignedURLOptions{