I am adding tokio-tracing to my code. I have following method that creates a new tokio async task.
#[instrument]
fn start_listener(mut listener: MyListener, should_stop: Receiver<()>) -> JoinHandle<()> {
tokio::spawn(async move {
tokio::select! {
result = listener.start() => {
match result {
Ok(()) => { },
Err(err) => {
println!("{}", err);
}
}
},
_ = should_stop => {
debug!("server stopped");
}
}
})
}
What's the best way to do it for this method. What I want is to receive tracing from the Listener.