Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Log Masking #281

Open
dgoetsch opened this issue Mar 8, 2021 · 1 comment
Open

Feature Request: Log Masking #281

dgoetsch opened this issue Mar 8, 2021 · 1 comment
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR.

Comments

@dgoetsch
Copy link

dgoetsch commented Mar 8, 2021

I'm using slog in a new production microservice. We make some API calls, and I want to be able to configure log masking for sensitive fields. For example, I want to mask out certain fields in the request/response bodies or certain headers by name. I don't see this supported in any of the modules I've checked, I believe this is a new feature.

Currently for a work around, I'm just doing an in memory map before sending to the logger, however I would prefer the logger handled this so I wouldn't have to write a bunch of custom code to iterate over collections. I also use the slog-json crate.

Any ideas or recommendations?

@dpc
Copy link
Collaborator

dpc commented Mar 9, 2021

You can just implement a Drain wrapping other Drains and rewritting things. It's a fairly common pattern. See https://docs.rs/slog/2.7.0/slog/trait.Drain.html#tymethod.log is a good starting point.

Another approach would be to write your own macros debug and alikes and in it do the heavy lifting. These would have potential to have faster runtime perf.

@Techcable Techcable added the C-feature-request Category: A feature request, i.e: not implemented / a PR. label Feb 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR.
Projects
None yet
Development

No branches or pull requests

3 participants