add SetLogLevelByName

This commit is contained in:
bryanqiu 2023-07-21 11:40:48 +08:00
parent ec1b3b298f
commit edecd4a8d7

4
log.go
View File

@ -94,9 +94,9 @@ func (log *Logger) SetLogLevel(newlv LogLevel) (oldlv LogLevel) {
// SetLogLevelByName set new log level by level name // SetLogLevelByName set new log level by level name
func (log *Logger) SetLogLevelByName(newlv string) (oldlv string) { func (log *Logger) SetLogLevelByName(newlv string) (oldlv string) {
if newlevel, ok := mapStrToLevel[newlv]; ok { if newlevel, ok := mapStrToLevel[newlv]; ok {
oldlv = log.loglevel oldlevel := log.loglevel
log.loglevel = newlevel log.loglevel = newlevel
return mapLevelToStr[oldlv] return mapLevelToStr[oldlevel]
} }
return ErrLogLevel return ErrLogLevel
} }