package logger

// log结构体
type message struct {
	Level    string `json:"level"`
	Module   string `json:"module"`
	Content  string `json:"content"`
	Date     string `json:"date"`
	Time     string `json:"time"`
	Caller   string `json:"caller"`
	Extra    string `json:"extra"` // 额外写入的json
	Pid      int    `json:"pid"`
	Operator string `json:"operator"`
}

const (
	debugLevel string = "debug"
	infoLevel  string = "info"
	warnLevel  string = "warn"
	errorLevel string = "error"
	fatalLevel string = "fatal"
	DebugLevel string = "Debug"
	InfoLevel  string = "Info"
	WarnLevel  string = "Warn"
	ErrorLevel string = "Error"
	FatalLevel string = "Fatal"
)

const (
	debugLevelInt int = iota
	infoLevelInt
	warnLevelInt
	errorLevelInt
	fatalLevelInt
)

// level string转成 level int
func changeToInt(level string) int {
	if level == debugLevel || level == DebugLevel {
		return debugLevelInt
	} else if level == infoLevel || level == InfoLevel {
		return infoLevelInt
	} else if level == warnLevel || level == WarnLevel {
		return warnLevelInt
	} else if level == errorLevel || level == ErrorLevel {
		return errorLevelInt
	} else {
		return fatalLevelInt
	}
}
