AFAIRE
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.4 KiB

/*
------------------------------------------------------------------------------------------------------------------------
####### logger ####### Copyright (c) 2021-2022 losyme ############################################## MIT License #######
------------------------------------------------------------------------------------------------------------------------
*/
package logger
type Level uint32
const (
LevelTrace = iota + 1
LevelDebug
LevelInfo
LevelNotice
LevelWarning
LevelError
LevelFatal
)
func StringToLevel(level string) Level {
switch level {
case "trace", "Trace", "TRACE":
return LevelTrace
case "debug", "Debug", "DEBUG":
return LevelDebug
case "info", "Info", "INFO":
return LevelInfo
case "notice", "Notice", "NOTICE":
return LevelNotice
case "warn", "Warn", "WARN", "warning", "Warning", "WARNING":
return LevelWarning
case "error", "Error", "ERROR":
return LevelError
case "fatal", "Fatal", "FATAL":
return LevelFatal
default:
return LevelInfo
}
}
func (l Level) String() string {
switch l {
case LevelTrace:
return "trace"
case LevelDebug:
return "debug"
case LevelInfo:
return "info"
case LevelNotice:
return "notice"
case LevelWarning:
return "warning"
case LevelError:
return "error"
case LevelFatal:
return "fatal"
default:
return "?"
}
}
/*
######################################################################################################## @(°_°)@ #######
*/