Struct slog_async::Async
source · pub struct Async { /* private fields */ }
Expand description
Async drain
Async
will send all the logging records to a wrapped drain running in
another thread.
Async
never returns AsyncError::Full
.
Record
s are passed to the worker thread through a channel with a bounded
size (see AsyncBuilder::chan_size
). On channel overflow Async
will
start dropping Record
s and log a message informing about it after
sending more Record
s is possible again. The exact details of handling
overflow is implementation defined, might change and should not be relied
on, other than message won’t be dropped as long as channel does not
overflow.
Any messages reported by Async
will contain slog-async
logging Record
tag to allow easy custom handling.
Note: On drop Async
waits for it’s worker-thread to finish (after handling
all previous Record
s sent to it). If you can’t tolerate the delay, make
sure you drop it eg. in another thread.
Implementations§
source§impl Async
impl Async
sourcepub fn default<D: Drain<Err = Never, Ok = ()> + Send + 'static>(
drain: D
) -> Self
pub fn default<D: Drain<Err = Never, Ok = ()> + Send + 'static>( drain: D ) -> Self
New AsyncCore
with default parameters
sourcepub fn new<D: Drain<Err = Never, Ok = ()> + Send + 'static>(
drain: D
) -> AsyncBuilder<D>
pub fn new<D: Drain<Err = Never, Ok = ()> + Send + 'static>( drain: D ) -> AsyncBuilder<D>
Build Async
drain with custom parameters
The wrapped drain must handle all results (Drain<Ok=(),Error=Never>
)
since there’s no way to return it back. See slog::DrainExt::fuse()
and
slog::DrainExt::ignore_res()
for typical error handling strategies.
Trait Implementations§
source§impl Drain for Async
impl Drain for Async
§type Err = AsyncError
type Err = AsyncError
Drain
source§fn log(
&self,
record: &Record<'_>,
logger_values: &OwnedKVList
) -> AsyncResult<()>
fn log( &self, record: &Record<'_>, logger_values: &OwnedKVList ) -> AsyncResult<()>
Record
) Read moresource§fn is_enabled(&self, level: Level) -> bool
fn is_enabled(&self, level: Level) -> bool
source§fn is_critical_enabled(&self) -> bool
fn is_critical_enabled(&self) -> bool
is_enabled
source§fn is_error_enabled(&self) -> bool
fn is_error_enabled(&self) -> bool
is_enabled
source§fn is_warning_enabled(&self) -> bool
fn is_warning_enabled(&self) -> bool
is_enabled
source§fn is_info_enabled(&self) -> bool
fn is_info_enabled(&self) -> bool
is_enabled
source§fn is_debug_enabled(&self) -> bool
fn is_debug_enabled(&self) -> bool
is_enabled
source§fn is_trace_enabled(&self) -> bool
fn is_trace_enabled(&self) -> bool
is_enabled
source§fn filter<F>(self, f: F) -> Filter<Self, F>where
Self: Sized,
F: FilterFn,
fn filter<F>(self, f: F) -> Filter<Self, F>where Self: Sized, F: FilterFn,
Drain
Read moresource§fn filter_level(self, level: Level) -> LevelFilter<Self>where
Self: Sized,
fn filter_level(self, level: Level) -> LevelFilter<Self>where Self: Sized,
Drain
(by level) Read more