about summary refs log tree commit diff
path: root/tools/nixery/server/config/config.go
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2019-10-06T02·18+0100
committerVincent Ambo <github@tazj.in>2019-10-06T22·05+0100
commit6f148f789f43bf753b345b039d01d8a429f194e9 (patch)
tree87569dd6d0d351822c926c250a20ed99e1f4452c /tools/nixery/server/config/config.go
parentf77c93b6aeb3e847fe00099ea5c52dc98cf74b4d (diff)
refactor(server): Convert existing log entries to structured format
This rewrites all existing log statements into the structured logrus
format. For consistency, all errors are always logged separately from
the primary message in a field called `error`.

Only the "info", "error" and "warn" severities are used.
Diffstat (limited to 'tools/nixery/server/config/config.go')
-rw-r--r--tools/nixery/server/config/config.go17
1 files changed, 13 insertions, 4 deletions
diff --git a/tools/nixery/server/config/config.go b/tools/nixery/server/config/config.go
index abc067855a..9447975aa9 100644
--- a/tools/nixery/server/config/config.go
+++ b/tools/nixery/server/config/config.go
@@ -32,14 +32,20 @@ func signingOptsFromEnv() *storage.SignedURLOptions {
 	id := os.Getenv("GCS_SIGNING_ACCOUNT")
 
 	if path == "" || id == "" {
-		log.Println("GCS URL signing disabled")
+		log.Info("GCS URL signing disabled")
 		return nil
 	}
 
-	log.Printf("GCS URL signing enabled with account %q\n", id)
+	log.WithFields(log.Fields{
+		"account": id,
+	}).Info("GCS URL signing enabled")
+
 	k, err := ioutil.ReadFile(path)
 	if err != nil {
-		log.Fatalf("Failed to read GCS signing key: %s\n", err)
+		log.WithFields(log.Fields{
+			"file":  path,
+			"error": err,
+		}).Fatal("failed to read GCS signing key")
 	}
 
 	return &storage.SignedURLOptions{
@@ -52,7 +58,10 @@ func signingOptsFromEnv() *storage.SignedURLOptions {
 func getConfig(key, desc, def string) string {
 	value := os.Getenv(key)
 	if value == "" && def == "" {
-		log.Fatalln(desc + " must be specified")
+		log.WithFields(log.Fields{
+			"option":      key,
+			"description": desc,
+		}).Fatal("missing required configuration envvar")
 	} else if value == "" {
 		return def
 	}