memonitor 0.2.4

Query CPU and GPU memory information in a portable way.
Documentation
use memonitor_sys::log::Level;
use std::ffi::{c_char, CStr};
use tracing::{debug, error, info, trace, warn};

const TARGET: &str = "memonitor-sys";

pub(super) unsafe extern "C" fn log(level: Level, text: *const c_char) {
    let text = unsafe {
        // SAFETY: `text` is a NUL-terminated C String
        CStr::from_ptr(text)
    };
    let text = text.to_string_lossy();

    match level {
        Level::Trace => trace!(target: TARGET, "{text}"),
        Level::Debug => debug!(target: TARGET, "{text}"),
        Level::Info => info!(target: TARGET, "{text}"),
        Level::Warn => warn!(target: TARGET, "{text}"),
        Level::Error => error!(target: TARGET, "{text}"),
    }
}