forked from mirror/logrus
Fix infinite recursion on unknown Level.String()
Using `%q` in the error string causes `MarshalText` to recurse (by calling String()).
This commit is contained in:
parent
cdb2f3857c
commit
4f5fd631f1
|
@ -74,7 +74,7 @@ func (level Level) MarshalText() ([]byte, error) {
|
||||||
return []byte("panic"), nil
|
return []byte("panic"), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, fmt.Errorf("not a valid lorus level %q", level)
|
return nil, fmt.Errorf("not a valid logrus level %d", level)
|
||||||
}
|
}
|
||||||
|
|
||||||
// A constant exposing all logging levels
|
// A constant exposing all logging levels
|
||||||
|
|
|
@ -521,6 +521,13 @@ func TestParseLevel(t *testing.T) {
|
||||||
assert.Equal(t, "not a valid logrus Level: \"invalid\"", err.Error())
|
assert.Equal(t, "not a valid logrus Level: \"invalid\"", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestLevelString(t *testing.T) {
|
||||||
|
var loggerlevel Level
|
||||||
|
loggerlevel = 32000
|
||||||
|
|
||||||
|
_ = loggerlevel.String()
|
||||||
|
}
|
||||||
|
|
||||||
func TestGetSetLevelRace(t *testing.T) {
|
func TestGetSetLevelRace(t *testing.T) {
|
||||||
wg := sync.WaitGroup{}
|
wg := sync.WaitGroup{}
|
||||||
for i := 0; i < 100; i++ {
|
for i := 0; i < 100; i++ {
|
||||||
|
|
Loading…
Reference in New Issue