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

@ -132,9 +132,7 @@ func (p *PkgsPath) CacheKey(pkgs []string, tag string) string {
// specified, the Nix code will default to a recent NixOS channel.
func pkgSourceFromEnv() (PkgSource, error) {
if channel := os.Getenv("NIXERY_CHANNEL"); channel != "" {
log.WithFields(log.Fields{
"channel": channel,
}).Info("using Nix package set from Nix channel or commit")
log.WithField("channel", channel).Info("using Nix package set from Nix channel or commit")
return &NixChannel{
channel: channel,
@ -142,9 +140,7 @@ func pkgSourceFromEnv() (PkgSource, error) {
}
if git := os.Getenv("NIXERY_PKGS_REPO"); git != "" {
log.WithFields(log.Fields{
"repo": git,
}).Info("using NIx package set from git repository")
log.WithField("repo", git).Info("using NIx package set from git repository")
return &GitSource{
repository: git,
@ -152,9 +148,7 @@ func pkgSourceFromEnv() (PkgSource, error) {
}
if path := os.Getenv("NIXERY_PKGS_PATH"); path != "" {
log.WithFields(log.Fields{
"path": path,
}).Info("using Nix package set at local path")
log.WithField("path", path).Info("using Nix package set at local path")
return &PkgsPath{
path: path,