Skip to content

Reinitialize / reset default tracing_subscriber::fmt max level #2431

Answered by hawkw
alcroito asked this question in Q&A
Discussion options

You must be logged in to vote

You can use the reload layer in tracing-subscriber to dynamically rebuild some or all of a global subscriber at runtime. This is similar to log, where the logger can only be set a single time, but specific implementations of that global logger/subscriber (e.g. log_reroute) allow changing its behavior after it's set.

In the specific use-case you described here, though, it's possible there are other solutions that might be nicer:

I would like to first initialise the global formatting subscriber with_max_level(Level::TRACE), run a bit of code, and then reinitialize (switch the max level) to Level::INFO.

Rather than setting the max level to TRACE, running some code, and then changing the ma…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@alcroito
Comment options

@alcroito
Comment options

Answer selected by alcroito
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants