Struct spdlog::LogCrateProxy
source · pub struct LogCrateProxy { /* private fields */ }log only.Expand description
Log crate proxy.
It forwards all log messages from log crate to default_logger by
default, and you can set a separate logger for it via
LogCrateProxy::set_logger.
If upstream dependencies use log crate to output log messages, they may
also be received by LogCrateProxy.
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 log_crate::set_max_level
with log_crate::LevelFilter.
Examples
use spdlog::log_crate as 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
impl LogCrateProxy
sourcepub fn swap_logger(&self, logger: Option<Arc<Logger>>) -> Option<Arc<Logger>>
pub fn swap_logger(&self, logger: Option<Arc<Logger>>) -> Option<Arc<Logger>>
Swaps a logger.
If the argument logger is None, the return value of
default_logger will be used.
sourcepub fn set_logger(&self, logger: Option<Arc<Logger>>)
pub fn set_logger(&self, logger: Option<Arc<Logger>>)
Sets a logger.
If the argument logger is None, the return value of
default_logger will be used.