update level #7
@@ -1,6 +1,7 @@
|
|||||||
package level
|
package level
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@@ -10,6 +11,10 @@ import (
|
|||||||
var (
|
var (
|
||||||
_ json.Marshaler = Level(0)
|
_ json.Marshaler = Level(0)
|
||||||
_ json.Unmarshaler = (*Level)(nil)
|
_ json.Unmarshaler = (*Level)(nil)
|
||||||
|
_ encoding.TextMarshaler = Level(0)
|
||||||
|
_ encoding.TextUnmarshaler = (*Level)(nil)
|
||||||
|
_ encoding.BinaryMarshaler = Level(0)
|
||||||
|
_ encoding.BinaryUnmarshaler = (*Level)(nil)
|
||||||
)
|
)
|
||||||
|
|
||||||
// Level log.
|
// Level log.
|
||||||
@@ -57,6 +62,17 @@ func (l *Level) UnmarshalText(in []byte) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (l Level) MarshalBinary() ([]byte, error) {
|
||||||
|
return []byte(l.String()), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *Level) UnmarshalBinary(in []byte) error {
|
||||||
|
lvl := Parse(string(in))
|
||||||
|
*l = lvl
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func Parse(lvl string) Level {
|
func Parse(lvl string) Level {
|
||||||
switch strings.ToLower(lvl) {
|
switch strings.ToLower(lvl) {
|
||||||
case "debug", "Debug", "DEBUG":
|
case "debug", "Debug", "DEBUG":
|
||||||
|
|||||||
Reference in New Issue
Block a user