logger: implement json.Unmarshaler

refs #10
This commit is contained in:
Christian Schwarz 2017-12-23 00:55:36 +01:00
parent 261d095108
commit f14dc3107f

View File

@ -15,6 +15,15 @@ func (l Level) MarshalJSON() ([]byte, error) {
return json.Marshal(l.String())
}
func (l *Level) UnmarshalJSON(input []byte) (err error) {
var s string
if err = json.Unmarshal(input, &s); err != nil {
return err
}
*l, err = ParseLevel(s)
return err
}
const (
Debug Level = iota
Info