destructurama / attributed

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

The ability to choose the logged text #14

Closed sturlath closed 6 years ago

sturlath commented 7 years ago

Have you any thoughts on extending the attribute to take in string so you could rather log *** instead of "not logged".

[NotLogged(Text= "***")]

Also I would like to be able to choose to not just override all but just part of the message. Like e.g in card numbers you can save first 4 and last 4. It would be great to be able to choose starting index and length

Something like [NotLogged(Char='*',Start=3, End=14)]

Just brainstorming here..

nblumhardt commented 7 years ago

Hi! Thanks for the suggestion.

How about...

[LogMasked]
// -> "*****"

[LogMasked(Text="####")]
// -> "####"

[LogMasked(Text="####", ShowFirst=5)]
// -> "12345####"

[LogMasked(ShowFirst=4, ShowLast=4)]
// -> "1234*****5678"

?

sturlath commented 7 years ago

My pleasure! Yes this is much better.

Would you then also include

[LogMasked(Text="####", ShowLast=4)] // -> "####5678"

nblumhardt commented 7 years ago

@sturlath yes, I think the idea would be for any combination of ShowFirst, Text and ShowLast to work 👍

sturlath commented 7 years ago

Hi better late than never.

I have a local commit with all this stuff we talked about. I have no experience with doing a pull request but I when I try to Push to dev I get this

Remote: Permission to destructurama/attributed.git denied to sturlath.

So I gather I just don´t have the rights. Right? Can you give them to me or can I somehow get you the updates for you to review?

The Git noob

nblumhardt commented 7 years ago

Great! :-)

You'll need to create your own fork in order to send the PR; the docs here have links to all the necessary info: https://help.github.com/articles/creating-a-pull-request/

Let me know if you need a hand. Cheers!

nblumhardt commented 6 years ago

Implemented in #16.