tracing-setup
tracing-setup
is a Rust crate that provides a structured way to configure and manage tracing with buffered logging. It introduces a BufferedLayer
that allows capturing and storing tracing events in a buffer, which can be flushed and printed as needed.
Features
- Buffered Logging: Captures tracing events in a buffer.
- Customizable Output: Supports different print types for events.
- Flushing Mechanism: Flushes buffered events to the console.
- Subscriber Integration: Easily integrates with
tracing
subscribers.
Usage
Add Dependency
Add the following to your Cargo.toml
:
[]
= "0.1.40"
= { = "0.3", = false, = ["fmt", "std", "env-filter"] }
= "2.1.0"
Example
Here's an example of how to use tracing-setup:
use ;
use ;
use Arc;
Structs and Traits
BufferedLayer
A layer that captures tracing events and stores them in a buffer.
Methods
new(tag: &str) -> Self
: Creates a new BufferedLayer with a specified tag.
flush(&self)
: Flushes the buffered events to the console.
BufferedSubscriberLayer
A subscriber layer that includes a BufferedLayer.
Methods
flush(&self)
: Flushes the buffered events using the inner BufferedLayer.
Flushable
A trait for flushing buffered events.
Functions
configure_tracing
Initializes the logging subscriber.
setup_buffered_tracing
Sets up a buffered tracing subscriber with an optional tag.
License
This project is licensed under the MIT License.