Skip to content

Commit

Permalink
Suppress log output for completion command.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjimti committed May 19, 2022
1 parent 4a5862b commit 9606341
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions cmd/kubefwd/kubefwd.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package main
import (
"bytes"
"fmt"
"io/ioutil"
"os"

log "github.com/sirupsen/logrus"
Expand All @@ -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 {
Expand Down Expand Up @@ -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(`| |/ / | | | '_ \ / _ \ |_\ \ /\ / / _ |`)
Expand Down

0 comments on commit 9606341

Please sign in to comment.