github.com/songzhibin97/gkit@v1.2.13/log/level.go (about)

     1  package log
     2  
     3  type Lever int8
     4  
     5  // 预定义Level等级
     6  const (
     7  	LevelDebug Lever = iota
     8  	LevelInfo
     9  	LevelWarn
    10  	LevelError
    11  )
    12  
    13  var m = map[Lever]string{
    14  	LevelDebug: "[Debug]",
    15  	LevelInfo:  "[Info]",
    16  	LevelWarn:  "[Warn]",
    17  	LevelError: "[Error]",
    18  }
    19  
    20  // Allow 允许是否可以打印
    21  func (l Lever) Allow(lv Lever) bool {
    22  	return lv >= l
    23  }
    24  
    25  // String 语义转义
    26  func (l Lever) String() string {
    27  	if v, ok := m[l]; ok {
    28  		return v
    29  	}
    30  	return "UNKNOWN"
    31  }