destructurama / attributed

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

Add a render masked string only method in `IPropertyDestructuringAttribute` #71

Closed juchom closed 7 months ago

juchom commented 1 year ago

Would it be possible to add a method to the interface that only return the masked string ?

The main reason behind this is to leverage this attributes in other parts of an application.

For exemple we have this class

public class ResetPassword
{
    [LogMasked]
    public string Password { get; set; }
    [LogMasked]
    public string ConfirmPassword { get; set; }
}

If I log this object with serilog everyhting is fine.

What would be great is to be able to have the rendered string directly in order to use them in custom exception's message for exemple.

github-actions[bot] commented 8 months ago

This issue was marked as stale since it has not been active for a long time

sungam3r commented 8 months ago

Would it be possible to add a method to the interface that only return the masked string ?

What interface?

sungam3r commented 8 months ago

If I understand correctly you need LogMaskedAttribute.FormatMaskedValue to be public.

sungam3r commented 8 months ago

new LogMaskedAttribute { ShowFirst = 3 }.GetMaskedValue("abcdef")

juchom commented 7 months ago

Hello,

To be honest, I don't remember what was my exact use case when I opened this issue.

But I was probably trying to have the properties rendered like it is in Serilog.

Probably an extension method like ToLoggingString() that applies the same transformation.

sungam3r commented 7 months ago

Do you still need such API?

juchom commented 7 months ago

I don't need it anymore right now.