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
use std::ffi::CString; use std::os::raw::{c_char, c_int}; extern "C" { fn __android_log_write(level: c_int, tag: *const c_char, message: *const c_char); } #[repr(i32)] pub enum AndroidLogPriority { Unknown = 0, Default = 1, Verbose = 2, Debug = 3, Info = 4, Warn = 5, Error = 6, Fatal = 7, Silent = 8, } pub fn android_log_write(level: AndroidLogPriority, tag: &str, message: &str) { let tag = CString::new(tag).unwrap(); let message = CString::new(message).unwrap(); unsafe { __android_log_write( level as i32, tag.as_c_str().as_ptr(), message.as_c_str().as_ptr(), ); } }