Skip to content

Commit

Permalink
Turn on SilenceErrors and SilenceUsage to prevent Cobra from messing …
Browse files Browse the repository at this point in the history
…up the stderr output

Signed-off-by: Richard Wall <[email protected]>
  • Loading branch information
wallrj committed Oct 31, 2024
1 parent cd4dd90 commit 23579e7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ Preflight checks are bundled into Packages`,
PersistentPreRun: func(cmd *cobra.Command, args []string) {
logs.Initialize()
},
// SilenceErrors and SilenceUsage prevents this command or any sub-command
// from printing arbitrary text to stderr.
// Why? To ensure that each line of output can be parsed as a single message
// for consumption by logging agents such as fluentd.
// Usage information is still available on stdout with the `-h` and `--help`
// flags.
SilenceErrors: true,
SilenceUsage: true,
}

func init() {
Expand Down

0 comments on commit 23579e7

Please sign in to comment.