blocky/log/logger_enum.go

161 lines
3.5 KiB
Go

// Code generated by go-enum DO NOT EDIT.
// Version:
// Revision:
// Build Date:
// Built By:
package log
import (
"fmt"
"strings"
)
const (
// FormatTypeText is a FormatType of type Text.
// logging as text
FormatTypeText FormatType = iota
// FormatTypeJson is a FormatType of type Json.
// JSON format
FormatTypeJson
)
const _FormatTypeName = "textjson"
var _FormatTypeNames = []string{
_FormatTypeName[0:4],
_FormatTypeName[4:8],
}
// FormatTypeNames returns a list of possible string values of FormatType.
func FormatTypeNames() []string {
tmp := make([]string, len(_FormatTypeNames))
copy(tmp, _FormatTypeNames)
return tmp
}
var _FormatTypeMap = map[FormatType]string{
0: _FormatTypeName[0:4],
1: _FormatTypeName[4:8],
}
// String implements the Stringer interface.
func (x FormatType) String() string {
if str, ok := _FormatTypeMap[x]; ok {
return str
}
return fmt.Sprintf("FormatType(%d)", x)
}
var _FormatTypeValue = map[string]FormatType{
_FormatTypeName[0:4]: 0,
_FormatTypeName[4:8]: 1,
}
// ParseFormatType attempts to convert a string to a FormatType
func ParseFormatType(name string) (FormatType, error) {
if x, ok := _FormatTypeValue[name]; ok {
return x, nil
}
return FormatType(0), fmt.Errorf("%s is not a valid FormatType, try [%s]", name, strings.Join(_FormatTypeNames, ", "))
}
// MarshalText implements the text marshaller method
func (x FormatType) MarshalText() ([]byte, error) {
return []byte(x.String()), nil
}
// UnmarshalText implements the text unmarshaller method
func (x *FormatType) UnmarshalText(text []byte) error {
name := string(text)
tmp, err := ParseFormatType(name)
if err != nil {
return err
}
*x = tmp
return nil
}
const (
// LevelInfo is a Level of type Info.
LevelInfo Level = iota
// LevelTrace is a Level of type Trace.
LevelTrace
// LevelDebug is a Level of type Debug.
LevelDebug
// LevelWarn is a Level of type Warn.
LevelWarn
// LevelError is a Level of type Error.
LevelError
// LevelFatal is a Level of type Fatal.
LevelFatal
)
const _LevelName = "infotracedebugwarnerrorfatal"
var _LevelNames = []string{
_LevelName[0:4],
_LevelName[4:9],
_LevelName[9:14],
_LevelName[14:18],
_LevelName[18:23],
_LevelName[23:28],
}
// LevelNames returns a list of possible string values of Level.
func LevelNames() []string {
tmp := make([]string, len(_LevelNames))
copy(tmp, _LevelNames)
return tmp
}
var _LevelMap = map[Level]string{
0: _LevelName[0:4],
1: _LevelName[4:9],
2: _LevelName[9:14],
3: _LevelName[14:18],
4: _LevelName[18:23],
5: _LevelName[23:28],
}
// String implements the Stringer interface.
func (x Level) String() string {
if str, ok := _LevelMap[x]; ok {
return str
}
return fmt.Sprintf("Level(%d)", x)
}
var _LevelValue = map[string]Level{
_LevelName[0:4]: 0,
_LevelName[4:9]: 1,
_LevelName[9:14]: 2,
_LevelName[14:18]: 3,
_LevelName[18:23]: 4,
_LevelName[23:28]: 5,
}
// ParseLevel attempts to convert a string to a Level
func ParseLevel(name string) (Level, error) {
if x, ok := _LevelValue[name]; ok {
return x, nil
}
return Level(0), fmt.Errorf("%s is not a valid Level, try [%s]", name, strings.Join(_LevelNames, ", "))
}
// MarshalText implements the text marshaller method
func (x Level) MarshalText() ([]byte, error) {
return []byte(x.String()), nil
}
// UnmarshalText implements the text unmarshaller method
func (x *Level) UnmarshalText(text []byte) error {
name := string(text)
tmp, err := ParseLevel(name)
if err != nil {
return err
}
*x = tmp
return nil
}