pub fn from_fn<F>(f: F) -> FromFn<F>
Expand description
Create a processor that processes incoming logs via a function.
§Examples
Internally, worker_task
uses from_fn
to allow the subscriber to send
trace data across a channel to a processing task.
use tokio::sync::mpsc;
use tracing_forest::processor;
let (tx, rx) = mpsc::unbounded_channel();
let sender_processor = processor::from_fn(move |tree| tx
.send(tree)
.map_err(|err| {
let msg = err.to_string().into();
processor::error(err.0, msg)
})
);
// -- snip --