Struct LogCrateProxy

Source
pub struct LogCrateProxy { /* private fields */ }
Available on crate feature log only.
Expand description

Proxy layer for compatible log crate.

Call init_log_crate_proxy to initialize the proxy, and then configure the proxy via log_crate_proxy.

After the proxy is initialized, it will forward all log messages from log crate to the global default logger or the logger set by LogCrateProxy::set_logger.

Note that the log crate uses a different log level filter and by default it rejects all log messages. To make LogCrateProxy able to receive log messages from log crate, you may need to call re_export::log::set_max_level with re_export::log::LevelFilter.

§Examples

use spdlog::re_export::log;

spdlog::init_log_crate_proxy()?;
// Enable all log messages from `log` crate.
log::set_max_level(log::LevelFilter::Trace);

For more and detailed examples, see ./examples directory.

Implementations§

Source§

impl LogCrateProxy

Source

pub fn swap_logger(&self, logger: Option<Arc<Logger>>) -> Option<Arc<Logger>>

Sets a logger as the new receiver, and returens the old one.

If the argument logger is None, the global default logger will be used.

Source

pub fn set_logger(&self, logger: Option<Arc<Logger>>)

Sets a logger as the new receiver.

If the argument logger is None, the global default logger will be used.

Trait Implementations§

Source§

impl Default for LogCrateProxy

Source§

fn default() -> LogCrateProxy

Returns the “default value” for a type. Read more
Source§

impl Log for LogCrateProxy

Source§

fn enabled(&self, metadata: &Metadata<'_>) -> bool

Determines if a log message with the specified metadata would be logged. Read more
Source§

fn log(&self, record: &Record<'_>)

Logs the Record. Read more
Source§

fn flush(&self)

Flushes any buffered records. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

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
Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.