Open moritzploss-k opened 6 months ago
Hi, and thanks for making zerolog. Maybe I'm missing something, but I fail to make zerolog work with a custom JSON encoder. This is my code:
zerolog
zerolog.InterfaceMarshalFunc = func(v any) ([]byte, error) { fmt.Print("hello") return json.MarshalIndent(v, "", strings.Repeat(" ", 4)) } log.Info().Msg("world")
I would expect zerolog to call my custom InterfaceMarshalFunc to marshal the JSON output (and print hello in the process), but all I get is this:
InterfaceMarshalFunc
hello
{"level":"info","message":"world"}
Am I missing something, or is this a bug?
This marshaler is only called when the Interface method is used for a given field. Zerolog does not provide a general pluggable marshaler.
Interface
alright, thanks for clarifying!
Description
Hi, and thanks for making
zerolog
. Maybe I'm missing something, but I fail to makezerolog
work with a custom JSON encoder. This is my code:I would expect
zerolog
to call my customInterfaceMarshalFunc
to marshal the JSON output (and printhello
in the process), but all I get is this:Am I missing something, or is this a bug?