From 9606341188fb6a5a72f49a3b8c10da87e74a8fd4 Mon Sep 17 00:00:00 2001 From: Craig Johnston Date: Thu, 19 May 2022 11:36:11 -0700 Subject: [PATCH] Suppress log output for completion command. --- cmd/kubefwd/kubefwd.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cmd/kubefwd/kubefwd.go b/cmd/kubefwd/kubefwd.go index c60bb1a6..6a414641 100644 --- a/cmd/kubefwd/kubefwd.go +++ b/cmd/kubefwd/kubefwd.go @@ -18,6 +18,7 @@ package main import ( "bytes" "fmt" + "io/ioutil" "os" log "github.com/sirupsen/logrus" @@ -35,6 +36,11 @@ func init() { fmt.Println(Version) os.Exit(0) } + + log.SetOutput(&LogOutputSplitter{}) + if len(args) > 0 && args[0] == "completion" { + log.SetOutput(ioutil.Discard) + } } func newRootCmd() *cobra.Command { @@ -81,14 +87,13 @@ func (splitter *LogOutputSplitter) Write(p []byte) (n int, err error) { } func main() { + log.SetFormatter(&log.TextFormatter{ FullTimestamp: true, ForceColors: true, TimestampFormat: "15:04:05", }) - log.SetOutput(&LogOutputSplitter{}) - log.Print(` _ _ __ _`) log.Print(`| | ___ _| |__ ___ / _|_ ____| |`) log.Print(`| |/ / | | | '_ \ / _ \ |_\ \ /\ / / _ |`)