destructurama / attributed

Use attributes to control how complex types are logged to Serilog.
Apache License 2.0
263 stars 32 forks source link

Add support for Dictionary<TKey, TValue> #41

Closed daniel-white closed 1 year ago

daniel-white commented 4 years ago

Json.NET has [ExtensionData] (see: https://www.newtonsoft.com/json/help/html/DeserializeExtensionData.htm). This is sometime used to allow for dynamic property population on deserialization.

By default, Serilog will capture all the pairs in a Dictionary<TKey, TValue>. I'm proposing that there is a way to do a whitelist or blacklist with configuring the value masking for each key or using a default if not configured. I'm thinking it would work similarly to xUnit's theory class data.

Another option is to transform the dictionary into a list of its keys and logging that.

SimonCropp commented 3 years ago

IMO this is getting too complex for an attribute based approach, so should be out of the scope of this project. @nblumhardt @sungam3r thoughts?

nblumhardt commented 3 years ago

Seems like a good candidate for a plug-in; this library supports IPropertyDestructuringAttribute and ITypeDestructuringAttribute, so should be possible to publish separately outside this project, and plug it in when desired. HTH!

sungam3r commented 2 years ago

Sorry for the late reply. I had a long break from OSS. @SimonCropp I agree that in may be too complex but I don't know without some API sketch. @daniel-white Could you please describe in more details your proposal.

sungam3r commented 1 year ago

Closed due to inactivity.