|
|
|
@ -1,6 +1,8 @@
|
|
|
|
|
package logsdk
|
|
|
|
|
|
|
|
|
|
import "fmt"
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Level 日志等级
|
|
|
|
|
type Level int
|
|
|
|
@ -12,6 +14,30 @@ func (level Level) String() string {
|
|
|
|
|
return "unknown"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ParseLevel 把 level 字符串解析成 Level,
|
|
|
|
|
// 支持的字符串: panic, fatal, error, warn, info, debug, trace,
|
|
|
|
|
// 传入不支持的字符串返回 LevelInfo.
|
|
|
|
|
func ParseLevel(s string) Level {
|
|
|
|
|
switch s {
|
|
|
|
|
case LevelPanicValue:
|
|
|
|
|
return LevelPanic
|
|
|
|
|
case LevelFatalValue:
|
|
|
|
|
return LevelFatal
|
|
|
|
|
case LevelErrorValue:
|
|
|
|
|
return LevelError
|
|
|
|
|
case LevelWarnValue:
|
|
|
|
|
return LevelWarn
|
|
|
|
|
case LevelInfoValue:
|
|
|
|
|
return LevelInfo
|
|
|
|
|
case LevelDebugValue:
|
|
|
|
|
return LevelDebug
|
|
|
|
|
case LevelTraceValue:
|
|
|
|
|
return LevelTrace
|
|
|
|
|
default:
|
|
|
|
|
return LevelInfo
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (level Level) MarshalText() ([]byte, error) {
|
|
|
|
|
switch level {
|
|
|
|
|
case LevelPanic:
|
|
|
|
|