pub struct LogContext { /* private fields */ }
Expand description
A log context saves informations about the current task, such as the elapsed time, the number of polls, and the poll time.
Implementations§
Source§impl LogContext
impl LogContext
Sourcepub fn new(tag: impl Into<Cow<'static, str>>) -> Self
pub fn new(tag: impl Into<Cow<'static, str>>) -> Self
Create a new log context with the given tag
Sourcepub fn maybe_with<F, R>(f: F) -> Option<R>where
F: FnOnce(&Self) -> R,
pub fn maybe_with<F, R>(f: F) -> Option<R>where
F: FnOnce(&Self) -> R,
Run a closure with the current log context, if any
Sourcepub fn run<F: FnOnce() -> Fut, Fut: Future>(
&self,
f: F,
) -> LogContextFuture<Fut>
pub fn run<F: FnOnce() -> Fut, Fut: Future>( &self, f: F, ) -> LogContextFuture<Fut>
Run the async function f
with the given log context. It will wrap the
output future to record poll and CPU statistics.
Sourcepub fn run_sync<F: FnOnce() -> R, R>(&self, f: F) -> R
pub fn run_sync<F: FnOnce() -> R, R>(&self, f: F) -> R
Run the sync function f
with the given log context, recording the CPU
time spent.
Sourcepub fn stats(&self) -> LogContextStats
pub fn stats(&self) -> LogContextStats
Create a snapshot of the log context statistics
Trait Implementations§
Source§impl Clone for LogContext
impl Clone for LogContext
Source§fn clone(&self) -> LogContext
fn clone(&self) -> LogContext
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for LogContext
impl RefUnwindSafe for LogContext
impl Send for LogContext
impl Sync for LogContext
impl Unpin for LogContext
impl UnwindSafe for LogContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more