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

     1  // This is a generated source file. DO NOT EDIT
     2  // Source: wasm/log_level__generated.go
     3  
     4  package consts
     5  
     6  import (
     7  	"bytes"
     8  	"database/sql/driver"
     9  	"errors"
    10  
    11  	"github.com/machinefi/w3bstream/pkg/depends/kit/enum"
    12  )
    13  
    14  var InvalidLogLevel = errors.New("invalid LogLevel type")
    15  
    16  func ParseLogLevelFromString(s string) (LogLevel, error) {
    17  	switch s {
    18  	default:
    19  		return LOG_LEVEL_UNKNOWN, InvalidLogLevel
    20  	case "":
    21  		return LOG_LEVEL_UNKNOWN, nil
    22  	case "ERROR":
    23  		return LOG_LEVEL__ERROR, nil
    24  	case "WARN":
    25  		return LOG_LEVEL__WARN, nil
    26  	case "INFO":
    27  		return LOG_LEVEL__INFO, nil
    28  	case "DEBUG":
    29  		return LOG_LEVEL__DEBUG, nil
    30  	}
    31  }
    32  
    33  func ParseLogLevelFromLabel(s string) (LogLevel, error) {
    34  	switch s {
    35  	default:
    36  		return LOG_LEVEL_UNKNOWN, InvalidLogLevel
    37  	case "":
    38  		return LOG_LEVEL_UNKNOWN, nil
    39  	case "ERROR":
    40  		return LOG_LEVEL__ERROR, nil
    41  	case "WARN":
    42  		return LOG_LEVEL__WARN, nil
    43  	case "INFO":
    44  		return LOG_LEVEL__INFO, nil
    45  	case "DEBUG":
    46  		return LOG_LEVEL__DEBUG, nil
    47  	}
    48  }
    49  
    50  func (v LogLevel) Int() int {
    51  	return int(v)
    52  }
    53  
    54  func (v LogLevel) String() string {
    55  	switch v {
    56  	default:
    57  		return "UNKNOWN"
    58  	case LOG_LEVEL_UNKNOWN:
    59  		return ""
    60  	case LOG_LEVEL__ERROR:
    61  		return "ERROR"
    62  	case LOG_LEVEL__WARN:
    63  		return "WARN"
    64  	case LOG_LEVEL__INFO:
    65  		return "INFO"
    66  	case LOG_LEVEL__DEBUG:
    67  		return "DEBUG"
    68  	}
    69  }
    70  
    71  func (v LogLevel) Label() string {
    72  	switch v {
    73  	default:
    74  		return "UNKNOWN"
    75  	case LOG_LEVEL_UNKNOWN:
    76  		return ""
    77  	case LOG_LEVEL__ERROR:
    78  		return "ERROR"
    79  	case LOG_LEVEL__WARN:
    80  		return "WARN"
    81  	case LOG_LEVEL__INFO:
    82  		return "INFO"
    83  	case LOG_LEVEL__DEBUG:
    84  		return "DEBUG"
    85  	}
    86  }
    87  
    88  func (v LogLevel) TypeName() string {
    89  	return "github.com/machinefi/w3bstream/pkg/modules/wasm.LogLevel"
    90  }
    91  
    92  func (v LogLevel) ConstValues() []enum.IntStringerEnum {
    93  	return []enum.IntStringerEnum{LOG_LEVEL__ERROR, LOG_LEVEL__WARN, LOG_LEVEL__INFO, LOG_LEVEL__DEBUG}
    94  }
    95  
    96  func (v LogLevel) MarshalText() ([]byte, error) {
    97  	s := v.String()
    98  	if s == "UNKNOWN" {
    99  		return nil, InvalidLogLevel
   100  	}
   101  	return []byte(s), nil
   102  }
   103  
   104  func (v *LogLevel) UnmarshalText(data []byte) error {
   105  	s := string(bytes.ToUpper(data))
   106  	val, err := ParseLogLevelFromString(s)
   107  	if err != nil {
   108  		return err
   109  	}
   110  	*(v) = val
   111  	return nil
   112  }
   113  
   114  func (v *LogLevel) Scan(src interface{}) error {
   115  	offset := 0
   116  	o, ok := interface{}(v).(enum.ValueOffset)
   117  	if ok {
   118  		offset = o.Offset()
   119  	}
   120  	i, err := enum.ScanIntEnumStringer(src, offset)
   121  	if err != nil {
   122  		return err
   123  	}
   124  	*(v) = LogLevel(i)
   125  	return nil
   126  }
   127  
   128  func (v LogLevel) Value() (driver.Value, error) {
   129  	offset := 0
   130  	o, ok := interface{}(v).(enum.ValueOffset)
   131  	if ok {
   132  		offset = o.Offset()
   133  	}
   134  	return int64(v) + int64(offset), nil
   135  }