[VOL-2760] Disable the clearing of the global log level setting
Change-Id: I26c35fa449126b036ddbb71db82d6da17b467b08
diff --git a/internal/pkg/commands/loglevel.go b/internal/pkg/commands/loglevel.go
index 2bdd5cf..acdc115 100644
--- a/internal/pkg/commands/loglevel.go
+++ b/internal/pkg/commands/loglevel.go
@@ -103,6 +103,11 @@
for _, component := range Components {
logConfig := model.LogLevel{}
val := strings.SplitN(component, "#", 2)
+
+ if strings.Contains(val[0], "/") {
+ return nil, errors.New("the component name '" + val[0] + "' contains an invalid character '/'")
+ }
+
if len(val) > 1 {
if val[0] == defaultComponentName {
return nil, errors.New("global level doesn't support packageName")
@@ -162,7 +167,7 @@
if options.Args.Level != "" {
if _, err := log.StringToLogLevel(options.Args.Level); err != nil {
- return fmt.Errorf("Unknown log level %s. Allowed values are INFO, DEBUG, ERROR, WARN, FATAL", options.Args.Level)
+ return fmt.Errorf("Unknown log level '%s'. Allowed values are DEBUG, INFO, WARN, ERROR, FATAL", options.Args.Level)
}
}
@@ -384,6 +389,10 @@
for _, lConfig := range logLevelConfig {
+ if lConfig.ComponentName == defaultComponentName {
+ return fmt.Errorf("The global default loglevel cannot be cleared.")
+ }
+
logConfig := cm.InitComponentConfig(lConfig.ComponentName, config.ConfigTypeLogLevel)
err := logConfig.Delete(ctx, lConfig.PackageName)