You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, when using logger.Debug().Interface("request_body", reqBody).Msg("request sent") to log the request detail with customized types, zerolog first assert if the "reqBody" is a LogObjectMarshaler or not, if not, it tries the std json marshaler to serialize the request body.
As you can see in the code snippet. It's hard coded to json.Marshal.
However, for performance and convenient, mostly we do not use the standard json package for json encode/decode now.
I hope zerolog could have a package level InterfaceMarshaler variable, and use it to marshal object when needed.
It has the same signature with json.Marshal, so everyone can replace the internal reflection based marshaler at runtime without forking zerolog.
PS: I am using jsoniter and have registered many customized encoders/decoders for customized types. That's why I hope zerolog can benefit from jsoniter without additional works.
The text was updated successfully, but these errors were encountered:
Currently, when using
logger.Debug().Interface("request_body", reqBody).Msg("request sent")
to log the request detail with customized types, zerolog first assert if the "reqBody" is aLogObjectMarshaler
or not, if not, it tries the std json marshaler to serialize the request body.As you can see in the code snippet. It's hard coded to
json.Marshal
.zerolog/internal/json/types.go
Lines 363 to 371 in 3c3b4a3
However, for performance and convenient, mostly we do not use the standard json package for json encode/decode now.
I hope zerolog could have a package level
InterfaceMarshaler
variable, and use it to marshal object when needed.It has the same signature with
json.Marshal
, so everyone can replace the internal reflection based marshaler at runtime without forking zerolog.PS: I am using jsoniter and have registered many customized encoders/decoders for customized types. That's why I hope zerolog can benefit from jsoniter without additional works.
The text was updated successfully, but these errors were encountered: