Comments (1)
👍, this would be nice to have.
Here's how I'd probably do it:
-
We could add a new function to
FmtSubscriber
that takes a new filter and changes the filter to the previous value. -
Then, we could use the subscriber downcasting API that was added in tokio-rs/tokio#974 to invoke that function on the
FmtSubscriber
. So, when we set the subscriber as the default, we could hold onto aDispatch
pointing to it, and use that to call the function that changes the filter, like this:dispatch.downcast_ref::<FmtSubscriber<...>>() .expect("Dispatch should still point to FmtSubscriber") .set_filter(new_filter);
We could also provide a free function or something that gets the current default
Dispatch
, tries to downcast it to aFmtSubscriber
, and calls theset_filter
function if it is one. -
For now, any subscriber which wishes to dynamically change its filter at runtime will need to return
Interest::sometimes
for all calls toregister_callsite
, so we would need some way of indicating whether or not this will occur when building theFmtSubscriber
. I have some thoughts on how to do that in a type safe way that guarantees the filter won't be modified unless we state that it can. -
Furthermore, we might want to consider adding an API to
tokio-trace-core
to allow completely invalidating and rebuilding all the cachedInterest
s. This would allow the subscriber to returnInterest::always
andInterest::never
, and invalidate the cached values only if the filter changes. This is almost certainly better for performance than re-evaluating the filters every time (although actually changing the filters would be a relatively slow operation). Adding a function like that to-core
is tracked by tokio-rs/tokio#1038.
from tracing.
Related Issues (20)
- Attribute for logging every line in the function HOT 2
- Leveled logging is ignoring RUST_LOG HOT 4
- `SubscriberBuilder::with_ansi` is incorrectly gated by the `ansi` feature in tracing-subscriber 0.3.18 HOT 1
- A Spans `on_close` method is called with 45 minutes delay HOT 3
- tracing-appender: log rotation doesn't work with musl target HOT 3
- Allow macro `instrument` to accept multiple `fields` and `skip` and merge them
- Broken link on docs.rs HOT 3
- non_blocking writer do not work HOT 4
- Make method env_var_name public HOT 1
- Broken link in documentation. HOT 2
- [tracing_subscriber::filter::Builder] Proposal for supporting multiple default directives / setting a default filter
- Unqualified `line!` macro usage inside `info!` causes issues with `ratatui_macros` HOT 1
- How to modify EnvFilter instead of replace HOT 3
- RollingFileAppender `prune_old_logs()` relies on `metadata().created()` which is not available on all platforms HOT 1
- Make Layer::with_writer not truncate the file HOT 4
- When will the feature(`valuable` suport`) be merged into stable version? HOT 1
- error[E0609]: no field `free` on type `REGISTRY` HOT 3
- Add an option for outputting span IDs HOT 1
- RollingFileAppender: prefix and suffix custom separator
- `#instrument` attribute not making new spans HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tracing.