Skip func pointer type value in fields
Before there was introduced a fix for JSONFormatter when func type value passed as Field. This commit does the same but for pointer to func. Ref: https://github.com/sirupsen/logrus/issues/642 https://github.com/sirupsen/logrus/pull/832
This commit is contained in:
@@ -113,3 +113,16 @@ func TestEntryHooksPanic(t *testing.T) {
|
||||
entry := NewEntry(logger)
|
||||
entry.Info(badMessage)
|
||||
}
|
||||
|
||||
func TestEntryWithIncorrectField(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
fn := func() {}
|
||||
|
||||
e := Entry{}
|
||||
eWithFunc := e.WithFields(Fields{"func": fn})
|
||||
eWithFuncPtr := e.WithFields(Fields{"funcPtr": &fn})
|
||||
|
||||
assert.Equal(eWithFunc.err, `can not add field "func"`)
|
||||
assert.Equal(eWithFuncPtr.err, `can not add field "funcPtr"`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user