Changed log to tracing
This commit is contained in:
parent
db12bba7a6
commit
48a14823fa
26 changed files with 321 additions and 689 deletions
|
|
@ -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)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue