Skip to main content

install_messages_subscriber

Function install_messages_subscriber 

Source
pub fn install_messages_subscriber(
    ring: Arc<Mutex<MessagesRing>>,
    bus: Arc<EventBus>,
    initial_filter: &str,
    stderr_enabled: bool,
) -> bool
Expand description

Install MessagesLayer as the global tracing subscriber, gated by an EnvFilter whose initial directive is initial_filter. The filter is reloadable – live edits via reload_messages_filter swap the directive without re-installing the subscriber.

Idempotent: only the first call wins; subsequent calls return false. The first call’s ring + bus are the ones every later event flows into; the first call’s initial_filter seeds the filter handle.

initial_filter accepts the standard tracing_subscriber::EnvFilter directive syntax (info, editor=info,lsp=debug, …). On parse failure the install falls back to info.

Why a global subscriber: tracing can only have one global default per process. Test isolation is handled by the layer’s ring/bus Arcs — every test that wants its own messages stream constructs its own MessagesLayer (without installing globally) and exercises on_event / emit directly.