Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature]set loglevel as flag #511

Merged
merged 1 commit into from
Nov 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions cmd/redisoperator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,9 @@ func (m *Main) Run() error {
errC := make(chan error)

// Set correct logging.
if m.flags.Debug {
err := m.logger.Set("debug")
if err != nil {
return err
}
m.logger.Debugf("debug mode activated")
err := m.logger.Set(log.Level(strings.ToLower(m.flags.LogLevel)))
if err != nil {
return err
}

// Create the metrics client.
Expand Down
5 changes: 2 additions & 3 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (
type CMDFlags struct {
KubeConfig string
Development bool
Debug bool
ListenAddr string
MetricsPath string
LogLevel string
}

// Init initializes and parse the flags
Expand All @@ -24,10 +24,9 @@ func (c *CMDFlags) Init() {
// register flags
flag.StringVar(&c.KubeConfig, "kubeconfig", kubehome, "kubernetes configuration path, only used when development mode enabled")
flag.BoolVar(&c.Development, "development", false, "development flag will allow to run the operator outside a kubernetes cluster")
flag.BoolVar(&c.Debug, "debug", false, "enable debug mode")
flag.StringVar(&c.ListenAddr, "listen-address", ":9710", "Address to listen on for metrics.")
flag.StringVar(&c.MetricsPath, "metrics-path", "/metrics", "Path to serve the metrics.")

flag.StringVar(&c.LogLevel, "log-level", "info", "set log level")
// Parse flags
flag.Parse()
}
Expand Down