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.
This commit is contained in:
parent
f77c93b6ae
commit
6f148f789f
7 changed files with 243 additions and 54 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,21 +132,30 @@ 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.Printf("Using Nix package set from Nix channel %q\n", channel)
|
||||
log.WithFields(log.Fields{
|
||||
"channel": channel,
|
||||
}).Info("using Nix package set from Nix channel or commit")
|
||||
|
||||
return &NixChannel{
|
||||
channel: channel,
|
||||
}, nil
|
||||
}
|
||||
|
||||
if git := os.Getenv("NIXERY_PKGS_REPO"); git != "" {
|
||||
log.Printf("Using Nix package set from git repository at %q\n", git)
|
||||
log.WithFields(log.Fields{
|
||||
"repo": git,
|
||||
}).Info("using NIx package set from git repository")
|
||||
|
||||
return &GitSource{
|
||||
repository: git,
|
||||
}, nil
|
||||
}
|
||||
|
||||
if path := os.Getenv("NIXERY_PKGS_PATH"); path != "" {
|
||||
log.Printf("Using Nix package set from path %q\n", path)
|
||||
log.WithFields(log.Fields{
|
||||
"path": path,
|
||||
}).Info("using Nix package set at local path")
|
||||
|
||||
return &PkgsPath{
|
||||
path: path,
|
||||
}, nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue