From 2092f2032d0407d3637fccce627c911fe4790c65 Mon Sep 17 00:00:00 2001 From: Andrew Mason Date: Wed, 27 Jan 2021 20:27:49 -0500 Subject: [PATCH] Set `SilenceErrors` on the root command, so we don't double-log Signed-off-by: Andrew Mason --- go/cmd/vtctldclient/internal/command/root.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/go/cmd/vtctldclient/internal/command/root.go b/go/cmd/vtctldclient/internal/command/root.go index 63ef37fe346..7243c8836e5 100644 --- a/go/cmd/vtctldclient/internal/command/root.go +++ b/go/cmd/vtctldclient/internal/command/root.go @@ -64,6 +64,14 @@ var ( return err }, TraverseChildren: true, + // By default, cobra will print any error returned by a child command to + // stderr, and then return that error back up the call chain. Since we + // use vitess's log package to log any error we get back from + // Root.Execute() (in ../../main.go) this actually results in duplicate + // stderr lines. So, somewhat counterintuitively, we actually "silence" + // all errors in cobra (just from being output, they still get + // propagated). + SilenceErrors: true, } )