pub fn init(dest: Option<Box<dyn Log>>, options: LoggerOptions)
Expand description
Initializes the logging system.
This takes a destination logger to which Sentry should forward all intercepted log messages and the options for the log handler.
Typically a log system in Rust will call log::set_logger
itself
but since we need to intercept this, a user of this function will
need to pass a logger to it instead of calling the init function of
the other crate.
For instance to use env_logger
with this one needs to do this:
ⓘ
use sentry::integrations::log;
use env_logger;
let builder = env_logger::Builder::from_default_env();
let logger = builder.build();
log::init(Some(Box::new(builder.build())), LoggerOptions {
global_filter: Some(logger.filter()),
..Default::default()
});
(For using env_logger
you can also use the env_logger
integration
which simplifies this).