log.rs (508B)
1 /// Print a message to the log 2 #[macro_export] 3 macro_rules! msg { 4 ($msg:expr) => { 5 $crate::log::drk_log($msg) 6 }; 7 ($($arg:tt)*) => ($crate::log::drk_log(&format!($($arg)*))); 8 } 9 10 #[inline] 11 pub fn drk_log(message: &str) { 12 #[cfg(target_arch = "wasm32")] 13 unsafe { 14 drk_log_(message.as_ptr(), message.len()); 15 } 16 17 #[cfg(not(target_arch = "wasm32"))] 18 println!("{}", message); 19 } 20 21 #[cfg(target_arch = "wasm32")] 22 extern "C" { 23 fn drk_log_(ptr: *const u8, len: usize); 24 }