SinkProp

Struct SinkProp 

Source
pub struct SinkProp { /* private fields */ }
Expand description

Contains definitions of sink properties.

It provides a set of common properties for sink to define. If there is no special need for properties, use it directly and then implement GetSinkProp for your sink, a blanket implementation will be enabled, which would eliminate a lot of boilerplate code.

If further customization of the properties is needed (e.g., using different types, changing behavior), this struct is not needed. Instead, define properties manually within your sink, and then implement SinkPropAccess.

Implementations§

Source§

impl SinkProp

Source

pub fn level_filter(&self) -> LevelFilter

Gets the log level filter.

Source

pub fn set_level_filter(&self, level_filter: LevelFilter)

Sets the log level filter.

Source

pub fn formatter<'a>(&'a self) -> impl Deref<Target = dyn Formatter> + 'a

Gets the formatter.

The returned value is a lock guard, so please avoid storing it in a variable with a longer lifetime.

Examples found in repository?
examples/05-sink.rs (line 39)
35    fn log(&self, record: &Record) -> spdlog::Result<()> {
36        let mut string_buf = StringBuf::new();
37        let mut ctx = FormatterContext::new();
38        self.prop
39            .formatter()
40            .format(record, &mut string_buf, &mut ctx)?;
41        self.collected.lock().unwrap().push(string_buf.to_string());
42        Ok(())
43    }
Source

pub fn set_formatter<F>(&self, formatter: F)
where F: Formatter + 'static,

Sets the formatter.

Source

pub fn set_formatter_boxed(&self, formatter: Box<dyn Formatter>)

Sets the boxed formatter.

Source

pub fn call_error_handler(&self, err: Error)

Calls the error handler with an error.

Source

pub fn set_error_handler<F: Into<ErrorHandler>>(&self, handler: F)

Sets a error handler.

Most errors that occur in Sink will be returned as directly as possible (e.g. returned to Logger), but some errors that cannot be returned immediately, this function will be called. For example, asynchronous errors.

Trait Implementations§

Source§

impl Default for SinkProp

Source§

fn default() -> Self

Returns a SinkProp with default values:

ParameterDefault Value
level_filterLevelFilter::All
formatterFullFormatter
error_handlerErrorHandler::default()

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.