You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
there was a way presented around 2 months ago in the matrix chat iirc ( end of october), where you could siphon the log output and still dont loose the local log.
use core::ffi::{c_char, c_int};
use esp_idf_sys::{size_t, va_list};
use log::info;
extern "C" {
#[allow(improper_ctypes)]
pub fn vsnprintf(_: *mut c_char, _: size_t, _: *const c_char, _: va_list) -> c_int;
}
#[allow(improper_ctypes_definitions)]
unsafe extern "C" fn vprintf_trampoline(arg1: *const c_char, arg2: va_list) -> c_int {
const MAX_LEN: usize = 128;
let mut buf = [0u8; MAX_LEN];
let len = vsnprintf(buf.as_mut_ptr() as _, MAX_LEN as _, arg1, arg2);
if len < 0 {
info!("vsnprintf returned an error: {len}");
return len;
}
let s = &buf[0..(len as usize).min(MAX_LEN)]; // the min is just in case
match core::str::from_utf8(s) {
Ok(s) => info!("esp log received: {s}"),
Err(err) => info!("esp log received a non-utf8 string: {err}, {s:?}"),
}
len
}
unsafe { esp_idf_sys::esp_log_set_vprintf(Some(vprintf_trampoline)) };
esp_idf_svc::log::EspLogger::initialize_default();
No description provided.
The text was updated successfully, but these errors were encountered: