Skip to content

Commit 35d6638

Browse files
committed
Turn on SilenceErrors and SilenceUsage to prevent Cobra from messing up the stderr output
Signed-off-by: Richard Wall <[email protected]>
1 parent 810b033 commit 35d6638

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

cmd/root.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ Preflight checks are bundled into Packages`,
2222
PersistentPreRun: func(cmd *cobra.Command, args []string) {
2323
logs.Initialize()
2424
},
25+
// SilenceErrors and SilenceUsage prevents this command or any sub-command
26+
// from printing arbitrary text to stderr.
27+
// Why? To ensure that each line of output can be parsed as a single message
28+
// for consumption by logging agents such as fluentd.
29+
// Usage information is still available on stdout with the `-h` and `--help`
30+
// flags.
31+
SilenceErrors: true,
32+
SilenceUsage: true,
2533
}
2634

2735
func init() {

0 commit comments

Comments
 (0)