1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
#[cfg(target_os = "android")] fn logging() { use android_logger::Config; use log::Level; android_logger::init_once(Config::default().with_min_level(Level::Debug)); } #[cfg(target_os = "ios")] fn logging() { use log::LevelFilter; use syslog::Facility; syslog::init_unix(Facility::LOG_USER, LevelFilter::max()).expect("could not connect to syslog"); } #[cfg(all(not(target_os = "ios"), not(target_os = "android")))] fn logging() {} pub fn setup_logger() { logging(); std::panic::set_hook(Box::new(|e| { log::error!("Error: {:?}", e); println!("Custom panic hook"); })); } #[macro_export] macro_rules! install { () => { #[no_mangle] pub extern "C" fn camarim_setup_logger() { camarim::setup_logger(); } }; }