mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
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:
@ -23,6 +23,8 @@ bytes = { version = "1.0" }
|
||||
crossbeam-utils = "0.8.7"
|
||||
lazy_static = "1.4.0"
|
||||
parking_lot = "0.12.1"
|
||||
tracing = { version = "0.1", features = ["log"] }
|
||||
|
||||
|
||||
lib-dispatch = { path = "../lib-dispatch" }
|
||||
flowy-core = { path = "../flowy-core" }
|
||||
|
@ -11,4 +11,6 @@ const uint8_t *sync_event(const uint8_t *input, uintptr_t len);
|
||||
|
||||
int32_t set_stream_port(int64_t port);
|
||||
|
||||
void link_me_please(void);
|
||||
void link_me_please(void);
|
||||
|
||||
void backend_log(int64_t level, const char *data);
|
||||
|
@ -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),
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user