FormatLogfmtValue should escape error and fmt.Stringer values

This commit is contained in:
Jared Wasinger 2023-11-15 16:34:50 +08:00
parent 3b7e759215
commit cdde508ef1

View file

@ -169,9 +169,9 @@ func FormatLogfmtValue(value interface{}, term bool) (result string) {
} }
switch v := value.(type) { switch v := value.(type) {
case error: case error:
return v.Error() return escapeString(v.Error())
case fmt.Stringer: case fmt.Stringer:
return v.String() return escapeString(v.String())
case bool: case bool:
return strconv.FormatBool(v) return strconv.FormatBool(v)
case float32: case float32: