chore: fix flutter log (#5038)

This commit is contained in:
Nathan.fooo 2024-04-02 20:02:45 +08:00 committed by GitHub
parent 4da624d2d3
commit 419600ca11
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 9 additions and 7 deletions

View File

@ -118,6 +118,7 @@ class SidebarWorkspace extends StatelessWidget {
} }
if (message != null) { if (message != null) {
Log.info('[Workspace] $message');
showSnackBarMessage(context, message); showSnackBarMessage(context, message);
} }
} }

View File

@ -21,7 +21,7 @@ use collab_plugins::local_storage::CollabPersistenceConfig;
use lib_infra::{if_native, if_wasm}; use lib_infra::{if_native, if_wasm};
use parking_lot::{Mutex, RwLock}; use parking_lot::{Mutex, RwLock};
use tracing::{error, trace}; use tracing::trace;
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub enum CollabPluginProviderType { pub enum CollabPluginProviderType {

View File

@ -51,6 +51,7 @@ dart = ["flowy-core/dart"]
rev-sqlite = ["flowy-core/rev-sqlite"] rev-sqlite = ["flowy-core/rev-sqlite"]
http_sync = ["flowy-core/http_sync", "flowy-core/use_bunyan"] http_sync = ["flowy-core/http_sync", "flowy-core/use_bunyan"]
openssl_vendored = ["flowy-core/openssl_vendored"] openssl_vendored = ["flowy-core/openssl_vendored"]
verbose_log = []
[build-dependencies] [build-dependencies]
flowy-codegen = { workspace = true, features = ["dart"] } flowy-codegen = { workspace = true, features = ["dart"] }

View File

@ -29,7 +29,6 @@ mod env_serde;
mod model; mod model;
mod notification; mod notification;
mod protobuf; mod protobuf;
mod util;
lazy_static! { lazy_static! {
static ref APPFLOWY_CORE: MutexAppFlowyCore = MutexAppFlowyCore::new(); static ref APPFLOWY_CORE: MutexAppFlowyCore = MutexAppFlowyCore::new();
@ -65,15 +64,13 @@ pub extern "C" fn init_sdk(_port: i64, data: *mut c_char) -> i64 {
let _ = save_appflowy_cloud_config(&configuration.root, &configuration.appflowy_cloud_config); let _ = save_appflowy_cloud_config(&configuration.root, &configuration.appflowy_cloud_config);
} }
let log_crates = vec!["flowy-ffi".to_string()];
let config = AppFlowyCoreConfig::new( let config = AppFlowyCoreConfig::new(
configuration.app_version, configuration.app_version,
configuration.custom_app_path, configuration.custom_app_path,
configuration.origin_app_path, configuration.origin_app_path,
configuration.device_id, configuration.device_id,
DEFAULT_NAME.to_string(), DEFAULT_NAME.to_string(),
) );
.log_filter("info", log_crates);
// Ensure that the database is closed before initialization. Also, verify that the init_sdk function can be called // Ensure that the database is closed before initialization. Also, verify that the init_sdk function can be called
// multiple times (is reentrant). Currently, only the database resource is exclusive. // multiple times (is reentrant). Currently, only the database resource is exclusive.
@ -95,6 +92,7 @@ pub extern "C" fn init_sdk(_port: i64, data: *mut c_char) -> i64 {
#[allow(clippy::let_underscore_future)] #[allow(clippy::let_underscore_future)]
pub extern "C" fn async_event(port: i64, input: *const u8, len: usize) { pub extern "C" fn async_event(port: i64, input: *const u8, len: usize) {
let request: AFPluginRequest = FFIRequest::from_u8_pointer(input, len).into(); let request: AFPluginRequest = FFIRequest::from_u8_pointer(input, len).into();
#[cfg(feature = "sync_verbose_log")]
trace!( trace!(
"[FFI]: {} Async Event: {:?} with {} port", "[FFI]: {} Async Event: {:?} with {} port",
&request.id, &request.id,
@ -113,6 +111,7 @@ pub extern "C" fn async_event(port: i64, input: *const u8, len: usize) {
dispatcher.as_ref(), dispatcher.as_ref(),
request, request,
move |resp: AFPluginEventResponse| { move |resp: AFPluginEventResponse| {
#[cfg(feature = "sync_verbose_log")]
trace!("[FFI]: Post data to dart through {} port", port); trace!("[FFI]: Post data to dart through {} port", port);
Box::pin(post_to_flutter(resp, port)) Box::pin(post_to_flutter(resp, port))
}, },
@ -122,6 +121,7 @@ pub extern "C" fn async_event(port: i64, input: *const u8, len: usize) {
#[no_mangle] #[no_mangle]
pub extern "C" fn sync_event(input: *const u8, len: usize) -> *const u8 { pub extern "C" fn sync_event(input: *const u8, len: usize) -> *const u8 {
let request: AFPluginRequest = FFIRequest::from_u8_pointer(input, len).into(); let request: AFPluginRequest = FFIRequest::from_u8_pointer(input, len).into();
#[cfg(feature = "sync_verbose_log")]
trace!("[FFI]: {} Sync Event: {:?}", &request.id, &request.event,); trace!("[FFI]: {} Sync Event: {:?}", &request.id, &request.event,);
let dispatcher = match APPFLOWY_CORE.dispatcher() { let dispatcher = match APPFLOWY_CORE.dispatcher() {
@ -162,6 +162,7 @@ async fn post_to_flutter(response: AFPluginEventResponse, port: i64) {
.await .await
{ {
Ok(_success) => { Ok(_success) => {
#[cfg(feature = "sync_verbose_log")]
trace!("[FFI]: Post data to dart success"); trace!("[FFI]: Post data to dart success");
}, },
Err(e) => { Err(e) => {

View File

@ -1 +0,0 @@

View File

@ -38,11 +38,11 @@ pub(crate) fn create_log_filter(level: String, with_crates: Vec<String>) -> Stri
filters.push(format!("flowy_server={}", level)); filters.push(format!("flowy_server={}", level));
filters.push(format!("flowy_notification={}", "info")); filters.push(format!("flowy_notification={}", "info"));
filters.push(format!("lib_infra={}", level)); filters.push(format!("lib_infra={}", level));
filters.push(format!("dart_ffi={}", level));
// ⚠Enable debug log for dart_ffi, flowy_sqlite and lib_dispatch as needed. Don't enable them by default. // ⚠Enable debug log for dart_ffi, flowy_sqlite and lib_dispatch as needed. Don't enable them by default.
{ {
// filters.push(format!("flowy_sqlite={}", "info")); // filters.push(format!("flowy_sqlite={}", "info"));
// filters.push(format!("dart_ffi={}", "info"));
// filters.push(format!("lib_dispatch={}", level)); // filters.push(format!("lib_dispatch={}", level));
} }