awl/logawl/logawl.go
grumbulon 8c61f9f409 logging (#1)
Promoting branch to master

Co-authored-by: grumbulon <grumbulon@dismail.de>
Reviewed-on: grumbulon/awl#1
2022-06-26 04:07:58 +00:00

44 lines
642 B
Go

package logawl
import "fmt"
type Lvl int
type Level struct {
lvl int
Prefix string
}
func (l *Level) GetLevel(i int) (string, error) {
switch i {
case int(FatalLevel):
return "FATAL ", nil
case int(ErrorLevel):
return "ERROR ", nil
case int(InfoLevel):
return "INFO ", nil
case int(DebugLevel):
return "DEBUG ", nil
}
return "", fmt.Errorf("Invalid log level choice")
}
var AllLevels = []Lvl{
FatalLevel,
ErrorLevel,
InfoLevel,
DebugLevel,
}
const (
// Fatal logs (will call exit(1))
FatalLevel Lvl = iota
// Error logs
ErrorLevel
// What is going on level
InfoLevel
// Verbose log level.
DebugLevel
)