logrus
logrus copied to clipboard
Fix func and file field clash (duplicated fields)
In case of:
- ReportCaller=true
-
func
and/orfile
fields are clased (set byWithField()
orWithFields()
)
The TextFormatter
duplicates the clashed func
and/or file
fields.
Root cause: prefixFieldClashes()
does not delete func
and/or file
fields, if it are renamed to fileds.func
and/or fields.file
. The TextFormatter.Format()
merges keys
and fixedKeys
, so func
and file
are duplicated in the merged slice, because TextFormatter.Format()
does not use unique list.
TestJSONFieldClashWithCaller
didn't detect this problem, because it uses unique data model (map instead of slice)
Solution:
- deleting
func
and/orfile
fields inprefixFieldClashes()
, if it are renamed. - new unit tests