change(build): Disable debug logging at compile time in release builds (#4516)

* Add zebrad features that disable debug logs at compile time

* By default, disable debug logs at compile time in release builds
This commit is contained in:
teor 2022-05-28 21:08:01 +10:00 committed by GitHub
parent 77d9d8f017
commit 9cc4584bc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 2 deletions

View File

@ -13,11 +13,26 @@ repository = "https://github.com/ZcashFoundation/zebra"
default-run = "zebrad" default-run = "zebrad"
[features] [features]
default = [] # In release builds, don't compile debug logging code, to improve performance.
default = ["release_max_level_info"]
# Production features that activate extra dependencies # Production features that activate extra dependencies
enable-sentry = ["sentry", "sentry-tracing"] enable-sentry = ["sentry", "sentry-tracing"]
# Production features that modify dependency behaviour
# Remove verbose logging at compile-time in release or all builds.
#
# Release builds are defined as "cfg(not(debug_assertions))".
# https://docs.rs/tracing/latest/tracing/level_filters/index.html#compile-time-filters
release_max_level_warn = ["tracing/release_max_level_warn", "log/release_max_level_warn"]
release_max_level_info = ["tracing/release_max_level_info", "log/release_max_level_info"]
release_max_level_debug = ["tracing/release_max_level_debug", "log/release_max_level_debug"]
max_level_warn = ["tracing/max_level_warn", "log/max_level_warn"]
max_level_info = ["tracing/max_level_info", "log/max_level_info"]
max_level_debug = ["tracing/max_level_debug", "log/max_level_debug"]
# Testing features that activate extra dependencies # Testing features that activate extra dependencies
proptest-impl = ["proptest", "proptest-derive", "zebra-chain/proptest-impl", "zebra-state/proptest-impl", "zebra-consensus/proptest-impl", "zebra-network/proptest-impl"] proptest-impl = ["proptest", "proptest-derive", "zebra-chain/proptest-impl", "zebra-state/proptest-impl", "zebra-consensus/proptest-impl", "zebra-network/proptest-impl"]
@ -75,8 +90,10 @@ rand = { version = "0.8.5", package = "rand" }
sentry-tracing = { version = "0.23.0", optional = true } sentry-tracing = { version = "0.23.0", optional = true }
sentry = { version = "0.23.0", default-features = false, features = ["backtrace", "contexts", "reqwest", "rustls"], optional = true } sentry = { version = "0.23.0", default-features = false, features = ["backtrace", "contexts", "reqwest", "rustls"], optional = true }
# prod feature release_max_level_info
#
# zebrad uses tracing for logging, # zebrad uses tracing for logging,
# we only use `log` to print the static log levels in transitive dependencies # we only use `log` to set and print the static log levels in transitive dependencies
log = "0.4.14" log = "0.4.14"
# test feature proptest-impl # test feature proptest-impl