You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We log mostly via the log crate.
We use the tracing and tracing-subscriber crates to configure logging.
For performance reasons, however, tracing is disabled statically for release builds in the public workspace.
As a consequence, any log configuration such as level filters does not apply anymore to log-emitted records -- that is, if one runs an executable with RUST_LOG=trace set, alllog records will be output.
This is not great, because it undermines nuanced log configuration within the private workspace.
For example, one might want to temporarily enable debug logging for a particular span (i.e. code path), without opening the floodgates of emitting all debug logs.
Proposed Solution
Configure tracing in the public workspace to use features = ["release_max_level_info"] by default
Change all #[instrument] annotations in the public workspace to use level = "trace" by default
We may later selectively raise the level of interesting spans created like this
Revise (default) log configuration for the private workspace (config.toml)
Confirm that hot-reloading of the log configuration still works (it seems it might not)
Optional: standardize on tracing instead of log, i.e. replace log::info!, log::debug! etc. with their tracing counterparts. tracing's support for "structured logging" (kv pairs) is invaluable in practice.
The text was updated successfully, but these errors were encountered:
Some more investigation reveals that setting features = ["release_max_level_*"] in the public workspace will completely prevent tracing from working in the private workspace.
We should set this feature only in the Cargo.toml of binary crates.
Disabling tracing (`features = ["release_max_level_off"]`) at the
workspace level prevents library users from using tracing at all.
Instead, set the feature for each binary individually.
Also change all but one `#[instrument]` macros to be at "trace" level,
which will prevent code gen unless the static level is at trace. This is
because most of them were introduced for `tracy` tracing, and may be at
"hot" code locations.
Fixes: #2117
Problem
We log mostly via the
log
crate.We use the
tracing
andtracing-subscriber
crates to configure logging.For performance reasons, however, tracing is disabled statically for release builds in the public workspace.
As a consequence, any log configuration such as level filters does not apply anymore to
log
-emitted records -- that is, if one runs an executable withRUST_LOG=trace
set, alllog
records will be output.This is not great, because it undermines nuanced log configuration within the private workspace.
For example, one might want to temporarily enable debug logging for a particular span (i.e. code path), without opening the floodgates of emitting all debug logs.
Proposed Solution
tracing
in the public workspace to usefeatures = ["release_max_level_info"]
by default#[instrument]
annotations in the public workspace to uselevel = "trace"
by defaulttracing
instead oflog
, i.e. replacelog::info!
,log::debug!
etc. with theirtracing
counterparts.tracing
's support for "structured logging" (kv pairs) is invaluable in practice.The text was updated successfully, but these errors were encountered: