Skip to content

Commit

Permalink
Merge pull request #110 from ipfs/fix/log-label-panic
Browse files Browse the repository at this point in the history
fix: don't panic on invalid log labels
  • Loading branch information
Stebalien committed Apr 17, 2021
2 parents fc55b72 + 967f31a commit 8621457
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,10 @@ func configFromEnv() Config {
labelKVs := strings.Split(labels, ",")
for _, label := range labelKVs {
kv := strings.Split(label, "=")
if len(kv) != 2 {
fmt.Fprint(os.Stderr, "invalid label k=v: ", label)
continue
}
cfg.Labels[kv[0]] = kv[1]
}
}
Expand Down
2 changes: 1 addition & 1 deletion setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func TestLogLabels(t *testing.T) {
}()

// set the go-log labels env var
os.Setenv(envLoggingLabels, "app=example_app,dc=sjc-1")
os.Setenv(envLoggingLabels, "app=example_app,dc=sjc-1,foobar") // foobar to ensure we don't panic on bad input.
SetupLogging(configFromEnv())

log := getLogger("test")
Expand Down

0 comments on commit 8621457

Please sign in to comment.