# tracing::subscriber::with_default - Rust
API documentation for the Rust `with_default` fn in crate `tracing`.
Keywords: rust, rustlang, rust-lang, with_default

# Function tracing::subscriber::with_default [−] [src]

    pub fn with_default<T, S>(subscriber: S, f: impl FnOnce() -> T) -> T where
        S: Subscriber + Send + Sync + 'static,

Sets this subscriber as the default for the duration of a closure.

The default subscriber is used when creating a new `Span` or `Event`, if no span is currently executing. If a span is currently executing, new spans or events are dispatched to the subscriber that tagged that span, instead.