dbsdk_rs/
db.rs

1use std::ffi::CString;
2use crate::db_internal::db_log;
3
4/// Print a formatted message to debug output
5#[macro_export]
6macro_rules! logfmt {
7    ($($arg:tt)*) => (log(format!($($arg)*).as_str()));
8}
9
10/// Prints a message to debug output
11pub fn log(str: &str) {
12    let cstr = CString::new(str).expect("Failed creating C string");
13    unsafe {
14        db_log(cstr.as_ptr());
15    }
16}
17
18/// Register custom DreamBox-specific panic handler
19pub fn register_panic() {
20    std::panic::set_hook(Box::new(|panic_info| {
21        logfmt!("FATAL ERROR: {}", panic_info);
22    }));
23}