mirror of
https://github.com/status-im/status-go.git
synced 2026-08-31 00:51:12 +00:00
* refactor: internal/crypto * refactor: internal/logutils * chore: internal/rpc * refactor: internal/accounts-management
29 lines
745 B
Go
29 lines
745 B
Go
package logutils
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"go.uber.org/zap/zapcore"
|
|
)
|
|
|
|
// LvlFromString returns the appropriate zapcore.Level from a string.
|
|
func LvlFromString(lvlString string) (zapcore.Level, error) {
|
|
switch strings.ToLower(lvlString) {
|
|
case "trace", "trce":
|
|
return traceLevel, nil // zap does not have a trace level, use custom
|
|
case "debug", "dbug":
|
|
return zapcore.DebugLevel, nil
|
|
case "info":
|
|
return zapcore.InfoLevel, nil
|
|
case "warn":
|
|
return zapcore.WarnLevel, nil
|
|
case "error", "eror":
|
|
return zapcore.ErrorLevel, nil
|
|
case "crit":
|
|
return zapcore.DPanicLevel, nil // zap does not have a crit level, using DPanicLevel as closest
|
|
default:
|
|
return zapcore.InvalidLevel, fmt.Errorf("unknown level: %v", lvlString)
|
|
}
|
|
}
|