Skip to content

Commit

Permalink
adding debug and quiet flags
Browse files Browse the repository at this point in the history
  • Loading branch information
luthermonson committed Dec 18, 2021
1 parent 1e6d727 commit 10cfe7b
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"fmt"
"io"
"io/ioutil"
"os"

"github.com/mattn/go-colorable"
Expand All @@ -13,6 +14,7 @@ import (
"github.com/rancher/wins/pkg/panics"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
"google.golang.org/grpc"
)

func main() {
Expand Down Expand Up @@ -49,16 +51,34 @@ func main() {
}

app.Commands = []cli.Command{
// server
server.NewCommand(),

// cli
client.NewCommand(),

// upgrade
upgrade.NewCommand(),
}

app.Flags = []cli.Flag{
&cli.BoolFlag{
Name: "debug",
Usage: "Turn on verbose debug logging",
},
&cli.BoolFlag{
Name: "quiet",
Usage: "Turn on off all logging",
},
}

app.Before = func(c *cli.Context) error {
if c.Bool("debug") {
logrus.SetLevel(logrus.DebugLevel)
grpc.EnableTracing = true
}
if c.Bool("quiet") {
logrus.SetOutput(ioutil.Discard)
}

return nil
}

if err := app.Run(os.Args); err != nil && err != io.EOF {
logrus.Fatal(err)
}
Expand Down

0 comments on commit 10cfe7b

Please sign in to comment.