tokio-rs / tracing

Application level tracing for Rust.
https://tracing.rs
MIT License
5.19k stars 677 forks source link

Better support for dynamically adjusting the filter #2899

Closed RalfJung closed 4 months ago

RalfJung commented 4 months ago

Feature Request

Motivation

I am trying to debug a nasty issue in Miri. I need to trace what happens during a certain part of the execution of the program. However, the issue starts billions of steps into the execution -- if I set the log-level to info, which enables per-step tracing in Miri, I will get hundreds of gigabytes of log before the interesting part of the execution even starts. So I'd like to start with no logging, and then when a certain event happens (programmatically detected inside the interpreter), I'd like to call some function in the tracing API that enables logging starting now.

Proposal

Tracing already has this notion of "subscribers", but it doesn't let me swap out the global subscriber so this doesn't help. I can set a per-thread subscriber, but:

I have no idea what the best way is to achieve this. I barely know tracing. All I know is I can set filters, and I want the filter to change during execution -- or something that has the equivalent effect.

Cc @oli-obk