diff --git a/README.md b/README.md index 5e5dbc0..3934c90 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,9 @@ Some other features included: The path to a Kubernetes configuration file (env KUBE_CONFIG) -kube-namespace string The namespace to watch or blank for all, which is the default (env KUBE_NAMESPACE) + -log-level value + Set a specific log filtering level, such as debug, info, warn, error + Ignored when --debug or --trace is used (env LOG_LEVEL) (default info) -mapping value Comma or newline delimited or repeated mappings of externalHostname=host:port (env MAPPING) -metrics-backend string diff --git a/cmd/mc-router/main.go b/cmd/mc-router/main.go index 01ea2e4..a058982 100644 --- a/cmd/mc-router/main.go +++ b/cmd/mc-router/main.go @@ -24,9 +24,10 @@ func showVersion() { } type CliConfig struct { - Version bool `usage:"Output version and exit"` - Debug bool `usage:"Enable debug logs"` - Trace bool `usage:"Enable trace logs"` + Version bool `usage:"Output version and exit"` + Debug bool `usage:"Enable debug logs"` + Trace bool `usage:"Enable trace logs"` + LogLevel logrus.Level `usage:"Set a specific log filtering level, such as debug, info, warn, error\nIgnored when --debug or --trace is used" default:"info"` ServerConfig server.Config `flatten:"true"` } @@ -49,6 +50,8 @@ func main() { } else if cliConfig.Debug { logrus.SetLevel(logrus.DebugLevel) logrus.Debug("Debug logs enabled") + } else { + logrus.SetLevel(cliConfig.LogLevel) } ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt)