feat: propagate log from flutter to rust backend (#1723)

* feat: draft commit for getting guidance on send log to backend issue

* feat: modify according to guidance

* feat: add tracing dependencies

* feat: continue implement for sending log to backend

* fix: compile errors

* feat: remove un-necessary code

---------

Co-authored-by: nathan <nathan@appflowy.io>
This commit is contained in:
Kelvin
2023-02-07 22:09:43 +08:00
committed by GitHub
parent 5004729b72
commit 781f0ab88b
9 changed files with 89 additions and 10 deletions

View File

@ -111,3 +111,19 @@ async fn post_to_flutter(response: AFPluginEventResponse, port: i64) {
}
}
}
#[no_mangle]
pub extern "C" fn backend_log(level: i64, data: *const c_char) {
let c_str = unsafe { CStr::from_ptr(data) };
let log_str = c_str.to_str().unwrap();
// Don't change the mapping relation between number and level
match level {
0 => tracing::info!("{}", log_str),
1 => tracing::debug!("{}", log_str),
2 => tracing::trace!("{}", log_str),
3 => tracing::warn!("{}", log_str),
4 => tracing::error!("{}", log_str),
_ => (),
}
}