fix saving and project improvments
This commit is contained in:
55
internal/config/log.go
Normal file
55
internal/config/log.go
Normal file
@ -0,0 +1,55 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"git.loyso.art/frx/eway/internal/entity"
|
||||
)
|
||||
|
||||
type LogLevel uint8
|
||||
|
||||
const (
|
||||
LogLevelDebug LogLevel = iota
|
||||
LogLevelInfo
|
||||
LogLevelWarn
|
||||
)
|
||||
|
||||
func (l *LogLevel) UnmarshalText(data []byte) (err error) {
|
||||
switch strings.ToLower(string(data)) {
|
||||
case "debug":
|
||||
*l = LogLevelDebug
|
||||
case "info":
|
||||
*l = LogLevelInfo
|
||||
case "warn":
|
||||
*l = LogLevelWarn
|
||||
default:
|
||||
return entity.SimpleError("unsupported level " + string(data))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type LogFormat uint8
|
||||
|
||||
const (
|
||||
LogFormatText LogFormat = iota
|
||||
LogFormatJSON
|
||||
)
|
||||
|
||||
func (l *LogFormat) UnmarshalText(data []byte) (err error) {
|
||||
switch strings.ToLower(string(data)) {
|
||||
case "text":
|
||||
*l = LogFormatText
|
||||
case "info":
|
||||
*l = LogFormatJSON
|
||||
default:
|
||||
return entity.SimpleError("unsupported format " + string(data))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type Log struct {
|
||||
Level string `json:"level"`
|
||||
Format string `json:"format"`
|
||||
}
|
||||
Reference in New Issue
Block a user