github.com/machinefi/w3bstream@v1.6.5-rc9.0.20240426031326-b8c7c4876e72/pkg/modules/wasm/consts/log_level.go (about)

     1  package consts
     2  
     3  import "log/slog"
     4  
     5  //go:generate toolkit gen enum LogLevel
     6  type LogLevel int32
     7  
     8  const (
     9  	LOG_LEVEL_UNKNOWN LogLevel = iota
    10  
    11  	_ // FATAL
    12  	LOG_LEVEL__ERROR
    13  	LOG_LEVEL__WARN
    14  	LOG_LEVEL__INFO
    15  	LOG_LEVEL__DEBUG
    16  	_ // TRACE
    17  )
    18  
    19  func (v LogLevel) Level() slog.Level {
    20  	switch v {
    21  	case LOG_LEVEL__ERROR:
    22  		return slog.LevelError
    23  	case LOG_LEVEL__WARN:
    24  		return slog.LevelWarn
    25  	case LOG_LEVEL__INFO:
    26  		return slog.LevelInfo
    27  	case LOG_LEVEL__DEBUG:
    28  		return slog.LevelDebug
    29  	default:
    30  		return slog.LevelInfo
    31  	}
    32  }