1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use std::{ffi::CString};
use crate::db_internal::db_log;

/// Prints a message to debug output
pub fn log(str: &str) {
    let cstr = CString::new(str).expect("Failed creating C string");
    unsafe {
        db_log(cstr.as_ptr());
    }
}

/// Register custom DreamBox-specific panic handler
pub fn register_panic() {
    std::panic::set_hook(Box::new(|panic_info| {
        log(format!("FATAL ERROR: {}", panic_info).as_str());
    }));
}