AsyncPoolSinkBuilder

Struct AsyncPoolSinkBuilder 

Source
pub struct AsyncPoolSinkBuilder { /* private fields */ }

Implementations§

Source§

impl AsyncPoolSinkBuilder

Source

pub fn sink(self, sink: Arc<dyn Sink>) -> Self

Available on crate feature multi-thread only.

Add a Sink.

Examples found in repository?
examples/07-async.rs (line 13)
8fn main() -> Result<(), Box<dyn std::error::Error>> {
9    let path = env::current_exe()?.with_file_name("async.log");
10    let file_sink = FileSink::builder().path(path).build_arc()?;
11
12    // AsyncPoolSink is a combined sink which wraps other sinks
13    let async_pool_sink = AsyncPoolSink::builder().sink(file_sink).build_arc()?;
14
15    let async_logger = Logger::builder()
16        .sink(async_pool_sink)
17        .flush_level_filter(LevelFilter::All)
18        .build_arc()?;
19
20    info!(logger: async_logger, "Hello, async!");
21
22    Ok(())
23}
Source

pub fn sinks<I>(self, sinks: I) -> Self
where I: IntoIterator<Item = Arc<dyn Sink>>,

Available on crate feature multi-thread only.

Add multiple Sinks.

Source

pub fn overflow_policy(self, overflow_policy: OverflowPolicy) -> Self

Available on crate feature multi-thread only.

Specifies a overflow policy.

This parameter is optional, and defaults to OverflowPolicy::Block.

When the channel is full, an incoming operation is handled according to the specified policy.

Source

pub fn thread_pool(self, thread_pool: Arc<ThreadPool>) -> Self

Available on crate feature multi-thread only.

Specifies a custom thread pool.

This parameter is optional, and defaults to the internal shared default thread pool.

Source

pub fn level_filter(self, level_filter: LevelFilter) -> Self

Available on crate feature multi-thread only.

Specifies a log level filter.

This parameter is optional, and defaults to LevelFilter::All.

Source

pub fn error_handler<F: Into<ErrorHandler>>(self, handler: F) -> Self

Available on crate feature multi-thread only.

Specifies an error handler.

This parameter is optional, and defaults to ErrorHandler::default().

Source

pub fn build(self) -> Result<AsyncPoolSink>

Available on crate feature multi-thread only.

Builds a AsyncPoolSink.

Source

pub fn build_arc(self) -> Result<Arc<AsyncPoolSink>>

Available on crate feature multi-thread only.

Builds a Arc<AsyncPoolSink>.

This is a shorthand method for .build().map(Arc::new).

Examples found in repository?
examples/07-async.rs (line 13)
8fn main() -> Result<(), Box<dyn std::error::Error>> {
9    let path = env::current_exe()?.with_file_name("async.log");
10    let file_sink = FileSink::builder().path(path).build_arc()?;
11
12    // AsyncPoolSink is a combined sink which wraps other sinks
13    let async_pool_sink = AsyncPoolSink::builder().sink(file_sink).build_arc()?;
14
15    let async_logger = Logger::builder()
16        .sink(async_pool_sink)
17        .flush_level_filter(LevelFilter::All)
18        .build_arc()?;
19
20    info!(logger: async_logger, "Hello, async!");
21
22    Ok(())
23}

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.