From 453a01881118b883917e575d3d25850339d61259 Mon Sep 17 00:00:00 2001 From: Karen Chen Date: Sat, 21 May 2022 14:47:27 -0700 Subject: [PATCH] added silent log level (#86) --- cmd/root.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/root.go b/cmd/root.go index 1ffff445..7e84a7c9 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -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{ @@ -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)) }, @@ -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.