Changed log to tracing

This commit is contained in:
Igor Katson 2023-11-19 12:50:11 +00:00
parent db12bba7a6
commit 48a14823fa
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
26 changed files with 321 additions and 689 deletions

View file

@ -1,22 +1,22 @@
use std::fmt::Display;
use tracing::{debug, error, trace, Instrument};
use log::{debug, error};
pub fn spawn<N: Display + 'static + Send>(
name: N,
pub fn spawn(
span: tracing::Span,
fut: impl std::future::Future<Output = anyhow::Result<()>> + Send + 'static,
) {
debug!("starting task \"{}\"", &name);
tokio::spawn(async move {
let fut = async move {
trace!("started");
match fut.await {
Ok(_) => {
debug!("task \"{}\" finished", &name);
debug!("finished");
}
Err(e) => {
error!("error in task \"{}\": {:#}", &name, e)
error!("{:#}", e)
}
}
});
}
.instrument(span.or_current());
tokio::spawn(fut);
}
#[derive(Clone, Copy, Debug)]