Skip to content

Commit

Permalink
update verbosity, add more log levels
Browse files Browse the repository at this point in the history
  • Loading branch information
ngtuna committed Dec 7, 2017
1 parent 2d4c89b commit 3d00ee1
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Find more information at https://github.com/kubeapps/kubeapps.`,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
out := cmd.OutOrStderr()
logrus.SetOutput(out)
verbosity, err := cmd.Flags().GetCount("verbose")
verbosity, err := cmd.Flags().GetString("verbose")
if err != nil {
return err
}
Expand All @@ -71,16 +71,24 @@ Find more information at https://github.com/kubeapps/kubeapps.`,
}

func init() {
RootCmd.PersistentFlags().CountP("verbose", "v", "Increase verbosity.")
RootCmd.PersistentFlags().StringP("verbose", "v", "warning", "Set log level: debug, info, warning, error, fatal, panic")
RootCmd.PersistentFlags().Set("logtostderr", "true")
}

func logLevel(verbosity int) logrus.Level {
func logLevel(verbosity string) logrus.Level {
switch verbosity {
case 0:
case "info":
return logrus.InfoLevel
default:
case "debug":
return logrus.DebugLevel
case "error":
return logrus.ErrorLevel
case "fatal":
return logrus.FatalLevel
case "panic":
return logrus.PanicLevel
default:
return logrus.WarnLevel
}
}

Expand Down

0 comments on commit 3d00ee1

Please sign in to comment.