1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-01-16 02:47:03 +02:00
kratos/log/level.go
Tony Chen 21557b38f6
log: add log context (#766)
* add log context & valuer
2021-03-14 15:36:00 +08:00

39 lines
659 B
Go

package log
// Level is a logger level.
type Level int8
// LevelKey is logger level key.
const LevelKey = "level"
const (
// LevelDebug is logger debug level.
LevelDebug Level = iota
// LevelInfo is logger info level.
LevelInfo
// LevelWarn is logger warn level.
LevelWarn
// LevelError is logger error level.
LevelError
)
// Enabled compare whether the logging level is enabled.
func (l Level) Enabled(lv Level) bool {
return lv >= l
}
func (l Level) String() string {
switch l {
case LevelDebug:
return "DEBUG"
case LevelInfo:
return "INFO"
case LevelWarn:
return "WARN"
case LevelError:
return "ERROR"
default:
return ""
}
}