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

feat: Disable logging in release build #28

Merged
merged 1 commit into from
Mar 8, 2023

Conversation

Pscheidl
Copy link
Contributor

@Pscheidl Pscheidl commented Mar 8, 2023

If this crate is used in a production environment with trace/debug logging level enabled, it prints out all secrets stored in envrionment variables to the logs. As most projects don't need environment variable logging at all, the logging feature is hidden behind a feature flag, completely avoiding runtime checks.

@Pscheidl
Copy link
Contributor Author

Pscheidl commented Mar 8, 2023

Having to opt-in for logging is a breaking change, but arguably is the most common use case ?

@Xuanwo
Copy link
Owner

Xuanwo commented Mar 8, 2023

Nice catch, lib like serde-env should not print any log to users. We can use log's native feature to implement this, like:

[dependencies]
log = { version = "0.4", features = ["max_level_trace", "release_max_level_off"] }

reference: https://docs.rs/log/latest/log/#compile-time-filters

@Xuanwo Xuanwo changed the title feat: Feature-flagged logging feat: Disable logging in release build Mar 8, 2023
@Pscheidl
Copy link
Contributor Author

Pscheidl commented Mar 8, 2023

Nice catch, lib like serde-env should not print any log to users. We can use log's native feature to implement this, like:

[dependencies]
log = { version = "0.4", features = ["max_level_trace", "release_max_level_off"] }

reference: https://docs.rs/log/latest/log/#compile-time-filters

That's very convenient, thanks. Made the changes. No point in opting in/out then.

@Xuanwo
Copy link
Owner

Xuanwo commented Mar 8, 2023

Thanks for your PR!

@Xuanwo Xuanwo merged commit 2dda1cb into Xuanwo:main Mar 8, 2023
@Pscheidl Pscheidl deleted the feature-flagged-logging branch March 8, 2023 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants