Flash messages using axum-messages
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use tokio::task::JoinHandle;
|
||||
use tracing_bunyan_formatter::{BunyanFormattingLayer, JsonStorageLayer};
|
||||
use tracing_subscriber::{fmt::MakeWriter, layer::SubscriberExt, util::SubscriberInitExt};
|
||||
|
||||
@@ -20,3 +21,12 @@ where
|
||||
.with(formatting_layer)
|
||||
.init();
|
||||
}
|
||||
|
||||
pub fn spawn_blocking_with_tracing<F, R>(f: F) -> JoinHandle<R>
|
||||
where
|
||||
F: FnOnce() -> R + Send + 'static,
|
||||
R: Send + 'static,
|
||||
{
|
||||
let current_span = tracing::Span::current();
|
||||
tokio::task::spawn_blocking(move || current_span.in_scope(f))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user