pinojs / pino-noir

🌲 pino log redaction 🍷
MIT License
66 stars 17 forks source link

Possible to redact partially? #5

Closed mrchief closed 6 years ago

mrchief commented 6 years ago

Is it possible to redact partially, like the way credit card numbers or SSN number are done?

E.g.

{ secret: "1234567890" } 

// outputs

{ secret: "xxxxxx7890" }

This will be very helpful to identify potential issues without delving the entire secret.

I think the easiest and most flexible way would be to accept a function? Something like this:

censor = (value) => {
// apply mask
return maskedValue
}

I understand this will cause a dip in performance which should be acceptable since this will be opt-in. And if there's a way to do it without sacrificing performance, even better!

Thoughts?

davidmarkclements commented 6 years ago

yes absolutely – I like it, we just need to ensure that there's no incidental performance hit on full redaction (e.g. ensure having to do a type of existence check doesn't reduce speed)

davidmarkclements commented 6 years ago

if you'd like to submit a PR (where censor can be a function) then it would be most welcome