2 releases
0.2.3 | Jul 1, 2020 |
---|---|
0.2.2 | Jun 29, 2020 |
#25 in #handlers
9KB
132 lines
Example
Cargo.toml example
full features
mylogger_handlers = {version="0.2.3", features=["full"]}
sentry features
mylogger_handlers = {version="0.2.3", features=["sentry_handler"]}
Sentry hanlder example
use mylogger::MyLogger;
use mylogger_handlers::sentry_handlers::SentryErrorHandler;
use log::{info, Level, LevelFilter};
#[test]
fn test_sentry() {
let dsn = "http://8427e6baa4c847a682eb5dbe3d560672@10.64.146.231:9000/2";
let mut mylogger = MyLogger::new("mylogger");
let sentry_handler =
SentryErrorHandler::new(Level::Info, "sentry".to_string(), dsn.to_string());
mylogger.register_handler(Box::new(sentry_handler));
log::set_boxed_logger(Box::new(mylogger)).map(|()| log::set_max_level(LevelFilter::Info));
let err = "NaN".parse::<usize>().unwrap_err();
for i in 0..5 {
error!("this is the error logger {:?} {:}", i, &err);
info!("this is the test logger {:?}", i);
}
}
Dependencies
~4–11MB
~110K SLoC