30 lines
399 B
Go
30 lines
399 B
Go
package lvl
|
|
|
|
type Level int
|
|
|
|
const (
|
|
Debug Level = iota
|
|
Info
|
|
Warn
|
|
Error
|
|
)
|
|
|
|
// String makes the Level to a string
|
|
func (l Level) String() string {
|
|
switch l {
|
|
case Debug:
|
|
return "Debug"
|
|
case Info:
|
|
return "Info"
|
|
case Warn:
|
|
return "Warn"
|
|
case Error:
|
|
return "Error"
|
|
}
|
|
return "Undefined"
|
|
}
|
|
|
|
func (l Level) MarshalJSON() ([]byte, error) {
|
|
return []byte("\"" + l.String() + "\""), nil
|
|
}
|