logger: serialize unknown fields to json

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi 2021-03-18 11:18:50 -07:00
parent 6cecde59fd
commit 5cd3aa5001

View File

@ -163,6 +163,12 @@ func (c *Console) formatFields(entry map[string]interface{}) string {
fields = append(fields, fmt.Sprintf("%s=%s", key, s)) fields = append(fields, fmt.Sprintf("%s=%s", key, s))
case nil: case nil:
fields = append(fields, fmt.Sprintf("%s=null", key)) fields = append(fields, fmt.Sprintf("%s=null", key))
default:
o, err := json.MarshalIndent(v, "", " ")
if err != nil {
panic(err)
}
fields = append(fields, fmt.Sprintf("%s=%s", key, o))
} }
} }