-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
[Posting as new issue because I think the comment on the other issue may have been missed]
I don't think this is quite right.
Consider the following:
#[derive(Clone, Debug, Default, Serialize, KV, SerdeValue)]
struct A {
#[serde(skip_serializing_if = "Option::is_none")]
b: Option<B>
}
#[derive(Clone, Debug, Default, Serialize, SerdeValue)]
struct B {
#[serde(skip_serializing_if = "Option::is_none")]
first: Option<String>,
second: Option<String>
}
[...]
let a = A::default();With (at least) slog_json, if I try and log that (info!(logger, "msg"; a);) I get the output
{
"b": null
}
I would expect {} as the output.
If I partially construct B like this:
let a = A {
b: Some(B {
first: Some("hello world".into()),
second: None,
}),
};
and log a again I get:
{
"b": {
"first": "hello world"
}
}
So skipping the option on the second field has worked.
If I remove the KV from the derive line, and write the log like info!(logger, "msg"; "a" => a); then the optional fields are correctly skipped, but everything is now under the "a" key in the output.
Originally posted by @nikclayton-dfinity in #5 (comment)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels