Skip to content

Commit

Permalink
send all log output to stderr (#209)
Browse files Browse the repository at this point in the history
Signed-off-by: Kent <[email protected]>
Signed-off-by: Kent Rancourt <[email protected]>
  • Loading branch information
krancour authored Oct 24, 2023
1 parent 4126d7d commit 161556b
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions cmd/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,15 @@ import (
)

func Run() {
// These two lines are required to suppress log output from the Argo CD repo
// server, which Kargo Render uses as a library.
//
// Without suppressing this, requests for machine-readable output (e.g. JSON)
// will be polluted with log output and attempts to parse it (e.g. by Kargo)
// will fail.
//
// This does NOT interfere with using the Kargo Render CLI's own --debug flag,
// however, choosing that will, once again, result in some amount of
// unparsable output.
// These two lines are required to suppress undesired log output from the Argo
// CD repo server, which Kargo Render uses as a library. This does NOT
// interfere with using the Kargo Render CLI's own --debug flag.
os.Setenv("ARGOCD_LOG_LEVEL", "PANIC")
log.SetLevel(log.PanicLevel)
// This line makes all log output go to stderr, leaving stdout for actual
// program output only. This is important for cases where machine readable
// output (e.g. JSON) is requested.
log.SetOutput(os.Stderr)

cmd, err := newRootCommand()
if err != nil {
Expand Down

0 comments on commit 161556b

Please sign in to comment.