Skip to content

Commit

Permalink
feat(logging): remove debug flag in favour of log level option
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Malet <michael@rubypx.com>
  • Loading branch information
Malet committed Oct 16, 2024
1 parent 76fad5d commit 2ec2b0f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions internal/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

var (
debug bool
logLevel string
compress bool
listen string
project string
Expand All @@ -18,14 +18,16 @@ var rootCmd = &cobra.Command{
Use: "iapc",
Long: "Utility for Google Cloud's Identity-Aware Proxy",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
if debug {
log.SetLevel(log.DebugLevel)
level, err := log.ParseLevel(logLevel)
if err != nil {
log.Warnf("could not set log level to %s, please use one of: {debug|info|warn|error|fatal}", logLevel)
}
log.SetLevel(level)
},
}

func init() {
rootCmd.PersistentFlags().BoolVar(&debug, "debug", false, "Enable debug logging")
rootCmd.PersistentFlags().StringVar(&logLevel, "log-level", "info", "Set log level")
rootCmd.PersistentFlags().BoolVarP(&compress, "compress", "c", false, "Enable WebSocket compression")
rootCmd.PersistentFlags().StringVarP(&listen, "listen", "l", "127.0.0.1:0", "Listen address and port")
rootCmd.PersistentFlags().StringVar(&project, "project", "", "Project ID")
Expand Down

0 comments on commit 2ec2b0f

Please sign in to comment.