[VOL-2356] removed Panic loglevel and added a method to convert loglevel from string to int
Change-Id: Idce562fd3da49004878ddf7dec5680c19e58b7bc
diff --git a/VERSION b/VERSION
index cd39aac..ef0bec0 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.2.26
+2.2.27
diff --git a/pkg/db/backend_test.go b/pkg/db/backend_test.go
index 5629355..6d2fb8a 100644
--- a/pkg/db/backend_test.go
+++ b/pkg/db/backend_test.go
@@ -30,7 +30,7 @@
)
func init() {
- log.AddPackage(log.JSON, log.PanicLevel, nil)
+ log.AddPackage(log.JSON, log.FatalLevel, nil)
}
const (
diff --git a/pkg/log/log.go b/pkg/log/log.go
index fe3a4e0..026c6c0 100644
--- a/pkg/log/log.go
+++ b/pkg/log/log.go
@@ -59,8 +59,6 @@
WarnLevel
// ErrorLevel logs a message at error level
ErrorLevel
- // PanicLevel logs a message, then panics.
- PanicLevel
// FatalLevel logs a message, then calls os.Exit(1).
FatalLevel
)
@@ -135,8 +133,6 @@
return zp.NewAtomicLevelAt(zc.WarnLevel)
case ErrorLevel:
return zp.NewAtomicLevelAt(zc.ErrorLevel)
- case PanicLevel:
- return zp.NewAtomicLevelAt(zc.PanicLevel)
case FatalLevel:
return zp.NewAtomicLevelAt(zc.FatalLevel)
}
@@ -153,8 +149,6 @@
return zc.WarnLevel
case ErrorLevel:
return zc.ErrorLevel
- case PanicLevel:
- return zc.PanicLevel
case FatalLevel:
return zc.FatalLevel
}
@@ -171,9 +165,23 @@
return WarnLevel
case zc.ErrorLevel:
return ErrorLevel
- case zc.PanicLevel:
- return PanicLevel
- case FatalLevel:
+ case zc.FatalLevel:
+ return FatalLevel
+ }
+ return ErrorLevel
+}
+
+func StringToInt(l string) int {
+ switch l {
+ case "DEBUG":
+ return DebugLevel
+ case "INFO":
+ return InfoLevel
+ case "WARN":
+ return WarnLevel
+ case "ERROR":
+ return ErrorLevel
+ case "FATAL":
return FatalLevel
}
return ErrorLevel
@@ -342,8 +350,6 @@
cfg.Level.SetLevel(zc.WarnLevel)
case ErrorLevel:
cfg.Level.SetLevel(zc.ErrorLevel)
- case PanicLevel:
- cfg.Level.SetLevel(zc.PanicLevel)
case FatalLevel:
cfg.Level.SetLevel(zc.FatalLevel)
default:
diff --git a/pkg/log/log_test.go b/pkg/log/log_test.go
index 88794b2..5ca0955 100644
--- a/pkg/log/log_test.go
+++ b/pkg/log/log_test.go
@@ -37,7 +37,7 @@
func verifyLogLevel(t *testing.T, minimumLevel int) {
SetAllLogLevel(minimumLevel)
var success bool
- for i := 0; i < 6; i++ {
+ for i := 0; i < 5; i++ {
success = testLogger.V(i)
if i == 1 && minimumLevel == 2 {
// TODO: Update the test when a new version of Zap logger is available. It has a bug with that
@@ -53,7 +53,7 @@
}
func TestLogLevelDebug(t *testing.T) {
- for i := 0; i < 6; i++ {
+ for i := 0; i < 5; i++ {
verifyLogLevel(t, i)
}
}
@@ -84,7 +84,7 @@
myLoggers[name], _ = AddPackage(JSON, ErrorLevel, nil, []string{name}...)
}
//Test updates to log levels
- levels := []int{0, 1, 2, 3, 4, 5}
+ levels := []int{0, 1, 2, 3, 4}
for _, expectedLevel := range levels {
for _, name := range pkgNames {
SetPackageLogLevel(name, expectedLevel)