zerolog icon indicating copy to clipboard operation
zerolog copied to clipboard

Inconsitance between `Interface()` and `Fields()`

Open slsyy opened this issue 4 years ago • 1 comments

Why these methods use a different mechanism for interface{} marshalling?

func ExampleInterface () {
	log := zerolog.New(os.Stdout)
	log.Info().Interface("foo", `<someXml></someXml>`).Send()

	// Output:
	// {"level":"info","foo":"\u003csomeXml\u003e\u003c/someXml\u003e"}
}

func ExampleFields () {
	log := zerolog.New(os.Stdout)
	log.Info().Fields(map[string]interface{}{"foo": `<someXml></someXml>`}).Send()

	// Output:
	// {"level":"info","foo":"<someXml></someXml>"}
}

slsyy avatar Aug 17 '21 08:08 slsyy

This should be fixed by #414.

mitar avatar Feb 23 '22 12:02 mitar