Skip to content

Panic in pretty formatter #3511

@nduchaux

Description

@nduchaux

Bug Report

Version

tracing-subscriber 0.3.23

Platform

Windows gnu

Description

I have a reloadable filter:

let layer: Box<dyn tracing_subscriber::Layer<_> + Send + Sync + 'static> = pretty_layer();
let (reload_layer, reload_handle) =  tracing_subscriber::reload::Layer::new(layer);


fn compact_layer()
-> Box<dyn tracing_subscriber::Layer<tracing_subscriber::Registry> + Send + Sync + 'static> {
    Box::new(
        tracing_subscriber::fmt::layer()
            .with_target(false)
            .compact(),
    )
}

fn pretty_layer()
-> Box<dyn tracing_subscriber::Layer<tracing_subscriber::Registry> + Send + Sync + 'static> {
    Box::new(
        tracing_subscriber::fmt::layer()
            .pretty()
            .with_file(true)
            .with_line_number(true)
            .with_target(true),
    )
}

I can change my layer formatting when I press a key. For example:

let _ = reload_handle.modify(|fmt_layer| *fmt_layer = pretty_layer()); // or the compact_layer() or others

Sometimes, I am getting a panic there in the pretty.rs file as soon as the layer is modified:

  let ext = span.extensions();
  let fields = &ext
      .get::<FormattedFields<N>>()
      .expect("Unable to find FormattedFields in extensions; this is a bug");

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions