use log::{debug, error, info, trace, warn};
use std::ffi::CStr;
pub(crate) unsafe extern "C" fn llama_log_callback(
level: llama_cpp_sys_2::ggml_log_level,
text: *const std::os::raw::c_char,
_data: *mut std::os::raw::c_void,
) {
let text = unsafe { CStr::from_ptr(text) };
let log_str = text.to_string_lossy();
let clean = log_str.trim_end();
match level {
llama_cpp_sys_2::GGML_LOG_LEVEL_DEBUG => debug!("{}", clean),
llama_cpp_sys_2::GGML_LOG_LEVEL_ERROR => error!("{}", clean),
llama_cpp_sys_2::GGML_LOG_LEVEL_WARN => warn!("{}", clean),
llama_cpp_sys_2::GGML_LOG_LEVEL_INFO => info!("{}", clean),
llama_cpp_sys_2::GGML_LOG_LEVEL_CONT => trace!("{}", log_str), _ => {} }
}