pub struct LogCrateProxy { /* private fields */ }
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
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>>
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.
Sourcepub fn set_logger(&self, logger: Option<Arc<Logger>>)
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.