Skip to content

Commit

Permalink
Added flag to control the logging level (#202)
Browse files Browse the repository at this point in the history
Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de>
  • Loading branch information
jpkrohling authored Feb 8, 2019
1 parent 0439aa5 commit 1a77e49
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pkg/cmd/start/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,25 @@ func NewStartCommand() *cobra.Command {
cmd.Flags().String("platform", "kubernetes", "The target platform the operator will run. Possible values: 'kubernetes' and 'openshift'")
viper.BindPFlag("platform", cmd.Flags().Lookup("platform"))

cmd.Flags().String("log-level", "info", "The log-level for the operator. Possible values: trace, debug, info, warning, error, fatal, panic")
viper.BindPFlag("log-level", cmd.Flags().Lookup("log-level"))

return cmd
}

func start(cmd *cobra.Command, args []string) {
level, err := log.ParseLevel(viper.GetString("log-level"))
if err != nil {
log.SetLevel(log.InfoLevel)
} else {
log.SetLevel(level)
}

log.WithFields(log.Fields{
"os": runtime.GOOS,
"arch": runtime.GOARCH,
"version": runtime.Version(),
}).Print("Go")
}).Info("Go")

log.WithField("version", version.Get().OperatorSdk).Print("operator-sdk")

Expand Down

0 comments on commit 1a77e49

Please sign in to comment.