Skip to content

Commit

Permalink
added silent log level (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
karenychen authored May 21, 2022
1 parent 55ab1b6 commit 453a018
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

var cfgFile string
var verbose bool
var silent bool

// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Expand All @@ -31,6 +32,9 @@ For more information, please visit the Draft Github page: https://github.com/Azu
PersistentPreRun: func(cmd *cobra.Command, args []string) {
if verbose {
logrus.SetLevel(logrus.DebugLevel)
} else if silent {
logrus.SetLevel(logrus.WarnLevel)

}
logrus.SetFormatter(new(logger.CustomFormatter))
},
Expand All @@ -55,6 +59,7 @@ func init() {

rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.draft.yaml)")
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "enable verbose logging")
rootCmd.PersistentFlags().BoolVarP(&silent, "silent", "", false, "enable silent logging")
}

// initConfig reads in config file and ENV variables if set.
Expand Down

0 comments on commit 453a018

Please sign in to comment.