44 lines
642 B
Go
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
|
|
)
|