fix saving and project improvments

This commit is contained in:
Aleksandr Trushkin
2024-01-25 16:42:08 +03:00
parent f94d39b124
commit 6fe250896c
17 changed files with 692 additions and 438 deletions

55
internal/config/log.go Normal file
View 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"`
}