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
36
37
38
use kos_sys::prelude::*;
use std::{
	ffi::CString,
	string::String,
};

pub enum DbgLevel {
    Dead,
    Critical,
    Error,
    Warning,
    Notice,
    Info,
    Debug,
    KDebug,
}

pub fn dbglog(level: DbgLevel, string: String) {
    let c_str = CString::new(string).unwrap();
    unsafe {
        kos_sys::os::dbglog::dbglog(level as c_int, c_str.as_ptr() as *const i8);
    }
}

#[macro_export]
macro_rules! dbglog {
    ($level:expr, $($arg:expr),+) => {
        {
            $crate::dbglog::dbglog($level, format!($($arg),+));
        }
    };
}

pub fn dbglog_set_level(level: DbgLevel) {
    unsafe {
        kos_sys::os::dbglog::dbglog_set_level(level as c_int);
    }
}