pub struct LayerBuilder<F, W, T> { /* private fields */ }
Expand description

A type for configuring TreeLayers.

See the module level documentation for details on using LayerBuilder.

Implementations

Applies a writer that is suitable for test environments.

Configuration methods can be chained on the return value.

Examples
tracing_forest::builder()
    .with_test_writer()
    .blocking_layer()
    .on_closure(|| {
        tracing::info!("Hello, world!");
    })

Applies the specified MakeWriter.

Configuration methods can be chained on the return value.

Examples
tracing_forest::builder()
    .with_writer(std::io::stderr)
    .blocking_layer()
    .on_closure(|| {
        tracing::info!("Hello, world!");
    })

Applies compact JSON formatting.

Configuration methods can be chained on the return value.

Examples
tracing_forest::builder()
    .json()
    .blocking_layer()
    .on_closure(|| {
        tracing::info!("Hello, world!");
    })
{"level":"INFO","kind":{"Event":{"tag":null,"message":"Hello, world!","fields":{}}}}

Applies pretty JSON formatting.

Configuration methods can be chained on the return value.

Examples
tracing_forest::builder()
    .json_pretty()
    .blocking_layer()
    .on_closure(|| {
        tracing::info!("Hello, world!");
    })
{
  "level": "INFO",
  "kind": {
    "Event": {
      "tag": null,
      "message": "Hello, world!",
      "fields": {}
    }
  }
}

Applies pretty formatting.

Configuration methods can be chained on the return value.

Examples
tracing_forest::builder()
    .json_pretty()
    .blocking_layer()
    .on_closure(|| {
        tracing::info!("Hello, world!");
    })
INFO     💬 [info]: Hello, world!

Applies a custom Formatter.

Configuration methods can be chained on the return value.

Examples
struct UselessFormatter;

impl Formatter for UselessFormatter {
    fn fmt(&self, _tree: Tree, writer: &mut Vec<u8>) -> io::Result<()> {
        writeln!(writer, "I am useless")
    }
}

tracing_forest::builder()
    .with_formatter(UselessFormatter)
    .blocking_layer()
    .on_closure(|| {
        tracing::info!("Hello, world!");
    })
I am useless

Applies a custom Tag.

Configuration methods can be chained on the return value.

Examples
tracing_forest::declare_tags! {
    use tracing_forest::Tag;

    #[derive(Tag)]
    pub(crate) enum MyTag {
        #[tag(lvl = "info", msg = "greeting", macro = "greeting")]
        Greeting,
    }
}

#[test]
tracing_forest::builder()
    .with_tag::<MyTag>()
    .blocking_layer()
    .on_closure(|| {
        greeting!("Hello, world!");
    })
INFO     💬 [greeting]: Hello, world!

Finalizes the layer to run with an AsyncProcessor.

Examples
tracing_forest::builder()
    .async_layer()
    .on_future(async {
        tracing::info!("Hello from Tokio");
    })
    .await

Finalizes the layer to run with a BlockingProcessor.

Examples
tracing_forest::builder()
    .blocking_layer()
    .on_closure(|| {
        tracing::info!("Hello from the current thread");
    })

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more