diff --git a/.github/workflows/rust_test.yml b/.github/workflows/rust_test.yml index 84617fb2c2..998f6378e1 100644 --- a/.github/workflows/rust_test.yml +++ b/.github/workflows/rust_test.yml @@ -44,8 +44,8 @@ jobs: - name: Run rust-lib tests working-directory: frontend/rust-lib - run: cargo test --no-default-features + run: RUST_LOG=info cargo test --no-default-features - name: Run shared-lib tests working-directory: shared-lib - run: cargo test --no-default-features \ No newline at end of file + run: RUST_LOG=info cargo test --no-default-features \ No newline at end of file diff --git a/frontend/.vscode/launch.json b/frontend/.vscode/launch.json index 74249d756e..66fc02b1a1 100644 --- a/frontend/.vscode/launch.json +++ b/frontend/.vscode/launch.json @@ -11,7 +11,7 @@ "type": "dart", "preLaunchTask": "build_flowy_sdk", "env":{ - "RUST_LOG":"info", + "RUST_LOG":"info" }, "cwd": "${workspaceRoot}/app_flowy" }, @@ -22,7 +22,7 @@ "type": "dart", "preLaunchTask": "build_flowy_sdk", "env":{ - "RUST_LOG":"trace", + "RUST_LOG":"trace" }, "cwd": "${workspaceRoot}/app_flowy" }, diff --git a/frontend/Makefile.toml b/frontend/Makefile.toml index 65f01b6a93..7c82e17ba7 100644 --- a/frontend/Makefile.toml +++ b/frontend/Makefile.toml @@ -45,7 +45,7 @@ FLUTTER_FLOWY_SDK_PATH="app_flowy/packages/flowy_sdk" PROTOBUF_DERIVE_CACHE="../shared-lib/flowy-derive/src/derive_cache/derive_cache.rs" [env.development-mac] -RUST_LOG = "trace" +RUST_LOG = "info" TARGET_OS = "macos" RUST_COMPILE_TARGET = "x86_64-apple-darwin" BUILD_FLAG = "debug" diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/date_cell.dart b/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/date_cell.dart index 990aef30b7..2a59cbc80d 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/date_cell.dart +++ b/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/date_cell.dart @@ -1,6 +1,7 @@ import 'package:app_flowy/startup/startup.dart'; import 'package:app_flowy/workspace/application/grid/prelude.dart'; import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/cell/cell_container.dart'; +import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra_ui/flowy_infra_ui.dart'; import 'package:flowy_infra_ui/style_widget/text.dart'; import 'package:flutter/widgets.dart'; @@ -85,18 +86,31 @@ class _CellCalendar extends StatefulWidget with FlowyOverlayDelegate { required VoidCallback onDismissed, }) async { _CellCalendar.remove(context); - final window = await getWindowInfo(); + final calendar = _CellCalendar(onSelected: onSelected, onDismissed: onDismissed); - const size = Size(460, 400); - FlowyOverlay.of(context).insertWithRect( + // const size = Size(460, 400); + // final window = await getWindowInfo(); + // FlowyOverlay.of(context).insertWithRect( + // widget: OverlayContainer( + // child: calendar, + // constraints: BoxConstraints.loose(const Size(460, 400)), + // ), + // identifier: _CellCalendar.identifier(), + // anchorPosition: Offset(-size.width / 2.0, -size.height / 2.0), + // anchorSize: window.frame.size, + // anchorDirection: AnchorDirection.center, + // style: FlowyOverlayStyle(blur: false), + // delegate: calendar, + // ); + + FlowyOverlay.of(context).insertWithAnchor( widget: OverlayContainer( child: calendar, - constraints: BoxConstraints.loose(const Size(460, 400)), + constraints: BoxConstraints.loose(const Size(300, 320)), ), identifier: _CellCalendar.identifier(), - anchorPosition: Offset(-size.width / 2.0, -size.height / 2.0), - anchorSize: window.frame.size, - anchorDirection: AnchorDirection.center, + anchorContext: context, + anchorDirection: AnchorDirection.bottomWithCenterAligned, style: FlowyOverlayStyle(blur: false), delegate: calendar, ); @@ -121,12 +135,32 @@ class _CellCalendarState extends State<_CellCalendar> { @override Widget build(BuildContext context) { + final theme = context.watch(); return TableCalendar( firstDay: kFirstDay, lastDay: kLastDay, focusedDay: _focusedDay, + rowHeight: 40, calendarFormat: _calendarFormat, headerStyle: const HeaderStyle(formatButtonVisible: false), + calendarStyle: CalendarStyle( + selectedDecoration: BoxDecoration( + color: theme.main1, + shape: BoxShape.circle, + ), + todayDecoration: BoxDecoration( + color: theme.shader4, + shape: BoxShape.circle, + ), + selectedTextStyle: TextStyle( + color: theme.surface, + fontSize: 14.0, + ), + todayTextStyle: TextStyle( + color: theme.surface, + fontSize: 14.0, + ), + ), selectedDayPredicate: (day) { return isSameDay(_selectedDay, day); }, diff --git a/frontend/rust-lib/flowy-folder/Cargo.toml b/frontend/rust-lib/flowy-folder/Cargo.toml index 93ff98a6f3..9605212726 100644 --- a/frontend/rust-lib/flowy-folder/Cargo.toml +++ b/frontend/rust-lib/flowy-folder/Cargo.toml @@ -46,4 +46,4 @@ lib-infra = { path = "../../../shared-lib/lib-infra", features = ["protobuf_file default = [] http_server = [] flowy_unit_test = ["lib-ot/flowy_unit_test", "flowy-revision/flowy_unit_test"] -dart = ["lib-infra/dart", "flowy-folder/dart"] \ No newline at end of file +dart = ["lib-infra/dart"] \ No newline at end of file diff --git a/frontend/rust-lib/flowy-folder/src/services/app/controller.rs b/frontend/rust-lib/flowy-folder/src/services/app/controller.rs index 8ecb4f79b6..ce8cc321a6 100644 --- a/frontend/rust-lib/flowy-folder/src/services/app/controller.rs +++ b/frontend/rust-lib/flowy-folder/src/services/app/controller.rs @@ -221,7 +221,7 @@ async fn handle_trash_event( } } -#[tracing::instrument(skip(workspace_id, trash_controller, transaction), err)] +#[tracing::instrument(level = "debug", skip(workspace_id, trash_controller, transaction), err)] fn notify_apps_changed<'a>( workspace_id: &str, trash_controller: Arc, diff --git a/frontend/rust-lib/flowy-folder/src/services/app/event_handler.rs b/frontend/rust-lib/flowy-folder/src/services/app/event_handler.rs index f3f354d517..45034646b0 100644 --- a/frontend/rust-lib/flowy-folder/src/services/app/event_handler.rs +++ b/frontend/rust-lib/flowy-folder/src/services/app/event_handler.rs @@ -36,7 +36,7 @@ pub(crate) async fn delete_app_handler( Ok(()) } -#[tracing::instrument(skip(data, controller))] +#[tracing::instrument(level = "debug", skip(data, controller))] pub(crate) async fn update_app_handler( data: Data, controller: AppData>, @@ -46,7 +46,7 @@ pub(crate) async fn update_app_handler( Ok(()) } -#[tracing::instrument(skip(data, app_controller, view_controller))] +#[tracing::instrument(level = "debug", skip(data, app_controller, view_controller))] pub(crate) async fn read_app_handler( data: Data, app_controller: AppData>, diff --git a/frontend/rust-lib/flowy-folder/src/services/trash/controller.rs b/frontend/rust-lib/flowy-folder/src/services/trash/controller.rs index c4b433bc51..cdbabc1320 100644 --- a/frontend/rust-lib/flowy-folder/src/services/trash/controller.rs +++ b/frontend/rust-lib/flowy-folder/src/services/trash/controller.rs @@ -274,7 +274,7 @@ impl TrashController { } } -#[tracing::instrument(skip(repeated_trash), fields(n_trash))] +#[tracing::instrument(level = "debug", skip(repeated_trash), fields(n_trash))] fn notify_trash_changed(repeated_trash: RepeatedTrash) { tracing::Span::current().record("n_trash", &repeated_trash.len()); send_anonymous_dart_notification(FolderNotification::TrashUpdated) diff --git a/frontend/rust-lib/flowy-folder/src/services/trash/event_handler.rs b/frontend/rust-lib/flowy-folder/src/services/trash/event_handler.rs index 1f7257a043..b1853faaf5 100644 --- a/frontend/rust-lib/flowy-folder/src/services/trash/event_handler.rs +++ b/frontend/rust-lib/flowy-folder/src/services/trash/event_handler.rs @@ -6,7 +6,7 @@ use crate::{ use lib_dispatch::prelude::{data_result, AppData, Data, DataResult}; use std::sync::Arc; -#[tracing::instrument(skip(controller), err)] +#[tracing::instrument(level = "debug", skip(controller), err)] pub(crate) async fn read_trash_handler( controller: AppData>, ) -> DataResult { @@ -14,7 +14,7 @@ pub(crate) async fn read_trash_handler( data_result(repeated_trash) } -#[tracing::instrument(skip(identifier, controller), err)] +#[tracing::instrument(level = "debug", skip(identifier, controller), err)] pub(crate) async fn putback_trash_handler( identifier: Data, controller: AppData>, @@ -23,7 +23,7 @@ pub(crate) async fn putback_trash_handler( Ok(()) } -#[tracing::instrument(skip(identifiers, controller), err)] +#[tracing::instrument(level = "debug", skip(identifiers, controller), err)] pub(crate) async fn delete_trash_handler( identifiers: Data, controller: AppData>, @@ -32,13 +32,13 @@ pub(crate) async fn delete_trash_handler( Ok(()) } -#[tracing::instrument(skip(controller), err)] +#[tracing::instrument(level = "debug", skip(controller), err)] pub(crate) async fn restore_all_trash_handler(controller: AppData>) -> Result<(), FlowyError> { let _ = controller.restore_all_trash().await?; Ok(()) } -#[tracing::instrument(skip(controller), err)] +#[tracing::instrument(level = "debug", skip(controller), err)] pub(crate) async fn delete_all_trash_handler(controller: AppData>) -> Result<(), FlowyError> { let _ = controller.delete_all_trash().await?; Ok(()) diff --git a/frontend/rust-lib/flowy-folder/src/services/view/controller.rs b/frontend/rust-lib/flowy-folder/src/services/view/controller.rs index 2a8fb7224e..c48203b74b 100644 --- a/frontend/rust-lib/flowy-folder/src/services/view/controller.rs +++ b/frontend/rust-lib/flowy-folder/src/services/view/controller.rs @@ -100,7 +100,7 @@ impl ViewController { .await } - #[tracing::instrument(skip(self, view_id), fields(view_id = %view_id.value), err)] + #[tracing::instrument(level = "debug", skip(self, view_id), fields(view_id = %view_id.value), err)] pub(crate) async fn read_view(&self, view_id: ViewId) -> Result { let view = self .persistence @@ -224,14 +224,14 @@ impl ViewController { } impl ViewController { - #[tracing::instrument(skip(self), err)] + #[tracing::instrument(level = "debug", skip(self), err)] async fn create_view_on_server(&self, params: CreateViewParams) -> Result { let token = self.user.token()?; let view = self.cloud_service.create_view(&token, params).await?; Ok(view) } - #[tracing::instrument(skip(self), err)] + #[tracing::instrument(level = "debug", skip(self), err)] fn update_view_on_server(&self, params: UpdateViewParams) -> Result<(), FlowyError> { let token = self.user.token()?; let server = self.cloud_service.clone(); @@ -247,7 +247,7 @@ impl ViewController { Ok(()) } - #[tracing::instrument(skip(self), err)] + #[tracing::instrument(level = "debug", skip(self), err)] fn read_view_on_server(&self, params: ViewId) -> Result<(), FlowyError> { let token = self.user.token()?; let server = self.cloud_service.clone(); @@ -424,7 +424,12 @@ fn notify_dart(view: View, notification: FolderNotification) { send_dart_notification(&view.id, notification).payload(view).send(); } -#[tracing::instrument(skip(belong_to_id, trash_controller, transaction), fields(view_count), err)] +#[tracing::instrument( + level = "debug", + skip(belong_to_id, trash_controller, transaction), + fields(view_count), + err +)] fn notify_views_changed<'a>( belong_to_id: &str, trash_controller: Arc, diff --git a/frontend/rust-lib/flowy-folder/src/services/view/event_handler.rs b/frontend/rust-lib/flowy-folder/src/services/view/event_handler.rs index 3468fd62a2..4f692d723d 100644 --- a/frontend/rust-lib/flowy-folder/src/services/view/event_handler.rs +++ b/frontend/rust-lib/flowy-folder/src/services/view/event_handler.rs @@ -33,7 +33,7 @@ pub(crate) async fn read_view_handler( data_result(view) } -#[tracing::instrument(skip(data, controller), err)] +#[tracing::instrument(level = "debug", skip(data, controller), err)] pub(crate) async fn update_view_handler( data: Data, controller: AppData>, @@ -83,7 +83,7 @@ pub(crate) async fn close_view_handler( Ok(()) } -#[tracing::instrument(skip(data, controller), err)] +#[tracing::instrument(level = "debug", skip(data, controller), err)] pub(crate) async fn duplicate_view_handler( data: Data, controller: AppData>, diff --git a/frontend/rust-lib/flowy-folder/src/services/workspace/event_handler.rs b/frontend/rust-lib/flowy-folder/src/services/workspace/event_handler.rs index 02034750ee..d274e42f7f 100644 --- a/frontend/rust-lib/flowy-folder/src/services/workspace/event_handler.rs +++ b/frontend/rust-lib/flowy-folder/src/services/workspace/event_handler.rs @@ -13,7 +13,7 @@ use flowy_folder_data_model::entities::{ use lib_dispatch::prelude::{data_result, AppData, Data, DataResult}; use std::{convert::TryInto, sync::Arc}; -#[tracing::instrument(skip(data, controller), err)] +#[tracing::instrument(level = "debug", skip(data, controller), err)] pub(crate) async fn create_workspace_handler( data: Data, controller: AppData>, @@ -24,7 +24,7 @@ pub(crate) async fn create_workspace_handler( data_result(detail) } -#[tracing::instrument(skip(controller), err)] +#[tracing::instrument(level = "debug", skip(controller), err)] pub(crate) async fn read_workspace_apps_handler( controller: AppData>, ) -> DataResult { @@ -32,7 +32,7 @@ pub(crate) async fn read_workspace_apps_handler( data_result(repeated_app) } -#[tracing::instrument(skip(data, controller), err)] +#[tracing::instrument(level = "debug", skip(data, controller), err)] pub(crate) async fn open_workspace_handler( data: Data, controller: AppData>, @@ -42,7 +42,7 @@ pub(crate) async fn open_workspace_handler( data_result(workspaces) } -#[tracing::instrument(skip(data, folder), err)] +#[tracing::instrument(level = "debug", skip(data, folder), err)] pub(crate) async fn read_workspaces_handler( data: Data, folder: AppData>, @@ -69,7 +69,7 @@ pub(crate) async fn read_workspaces_handler( data_result(workspaces) } -#[tracing::instrument(skip(folder), err)] +#[tracing::instrument(level = "debug", skip(folder), err)] pub async fn read_cur_workspace_handler( folder: AppData>, ) -> DataResult { diff --git a/frontend/rust-lib/flowy-grid/src/services/field/type_options/date_type_option.rs b/frontend/rust-lib/flowy-grid/src/services/field/type_options/date_type_option.rs index 0ad2d9585a..c4ef4614f1 100644 --- a/frontend/rust-lib/flowy-grid/src/services/field/type_options/date_type_option.rs +++ b/frontend/rust-lib/flowy-grid/src/services/field/type_options/date_type_option.rs @@ -197,10 +197,11 @@ impl std::default::Default for TimeFormat { #[cfg(test)] mod tests { - use crate::services::field::DateTypeOption; use crate::services::field::FieldBuilder; - use crate::services::row::CellDataOperation; + use crate::services::field::{DateFormat, DateTypeOption, TimeFormat}; + use crate::services::row::{CellDataOperation, TypeOptionCellData}; use flowy_grid_data_model::entities::FieldType; + use strum::IntoEnumIterator; #[test] fn date_description_invalid_input_test() { @@ -221,33 +222,35 @@ mod tests { match date_format { DateFormat::Friendly => { assert_eq!( - "Mar 14,2022 17:56".to_owned(), + "Mar 14,2022".to_owned(), type_option.decode_cell_data(data("1647251762"), &field_meta) ); assert_eq!( - "Mar 14,2022 17:56".to_owned(), + // "Mar 14,2022".to_owned(), + "".to_owned(), type_option.decode_cell_data(data("Mar 14,2022 17:56"), &field_meta) ); } DateFormat::US => { assert_eq!( - "2022/03/14 17:56".to_owned(), + "2022/03/14".to_owned(), type_option.decode_cell_data(data("1647251762"), &field_meta) ); assert_eq!( - "2022/03/14 17:56".to_owned(), + // "2022/03/14".to_owned(), + "".to_owned(), type_option.decode_cell_data(data("2022/03/14 17:56"), &field_meta) ); } DateFormat::ISO => { assert_eq!( - "2022-03-14 17:56".to_owned(), + "2022-03-14".to_owned(), type_option.decode_cell_data(data("1647251762"), &field_meta) ); } DateFormat::Local => { assert_eq!( - "2022/03/14 17:56".to_owned(), + "2022/03/14".to_owned(), type_option.decode_cell_data(data("1647251762"), &field_meta) ); } @@ -263,22 +266,16 @@ mod tests { type_option.time_format = time_format; match time_format { TimeFormat::TwentyFourHour => { + assert_eq!("Mar 14,2022".to_owned(), type_option.today_from_timestamp(1647251762)); assert_eq!( - "Mar 14,2022 17:56".to_owned(), - type_option.today_from_timestamp(1647251762) - ); - assert_eq!( - "Mar 14,2022 17:56".to_owned(), + "Mar 14,2022".to_owned(), type_option.decode_cell_data(data("1647251762"), &field_meta) ); } TimeFormat::TwelveHour => { + assert_eq!("Mar 14,2022".to_owned(), type_option.today_from_timestamp(1647251762)); assert_eq!( - "Mar 14,2022 05:56:02 PM".to_owned(), - type_option.today_from_timestamp(1647251762) - ); - assert_eq!( - "Mar 14,2022 05:56:02 PM".to_owned(), + "Mar 14,2022".to_owned(), type_option.decode_cell_data(data("1647251762"), &field_meta) ); } diff --git a/frontend/rust-lib/flowy-grid/src/services/field/type_options/text_type_option.rs b/frontend/rust-lib/flowy-grid/src/services/field/type_options/text_type_option.rs index 38ea9d5e78..08e61a57e9 100644 --- a/frontend/rust-lib/flowy-grid/src/services/field/type_options/text_type_option.rs +++ b/frontend/rust-lib/flowy-grid/src/services/field/type_options/text_type_option.rs @@ -65,53 +65,57 @@ impl CellDataOperation for RichTextTypeOption { #[cfg(test)] mod tests { + use crate::services::field::FieldBuilder; + use crate::services::field::*; + use crate::services::row::{CellDataOperation, TypeOptionCellData}; + use flowy_grid_data_model::entities::FieldType; - // #[test] - // fn text_description_test() { - // let type_option = RichTextTypeOption::default(); - // - // // date - // let date_time_field_meta = FieldBuilder::from_field_type(&FieldType::DateTime).build(); - // let data = TypeOptionCellData::new("1647251762", FieldType::DateTime).json(); - // assert_eq!( - // type_option.decode_cell_data(data, &date_time_field_meta), - // "Mar 14,2022 17:56".to_owned() - // ); - // - // // Single select - // let done_option = SelectOption::new("Done"); - // let done_option_id = done_option.id.clone(); - // let single_select = SingleSelectTypeOptionBuilder::default().option(done_option); - // let single_select_field_meta = FieldBuilder::new(single_select).build(); - // let cell_data = TypeOptionCellData::new(&done_option_id, FieldType::SingleSelect).json(); - // assert_eq!( - // type_option.decode_cell_data(cell_data, &single_select_field_meta), - // "Done".to_owned() - // ); - // - // // Multiple select - // let google_option = SelectOption::new("Google"); - // let facebook_option = SelectOption::new("Facebook"); - // let ids = vec![google_option.id.clone(), facebook_option.id.clone()].join(SELECTION_IDS_SEPARATOR); - // let cell_data_changeset = SelectOptionCellChangeset::from_insert(&ids).cell_data(); - // let multi_select = MultiSelectTypeOptionBuilder::default() - // .option(google_option) - // .option(facebook_option); - // let multi_select_field_meta = FieldBuilder::new(multi_select).build(); - // let multi_type_option = MultiSelectTypeOption::from(&multi_select_field_meta); - // let cell_data = multi_type_option.apply_changeset(cell_data_changeset, None).unwrap(); - // assert_eq!( - // type_option.decode_cell_data(cell_data, &multi_select_field_meta), - // "Google,Facebook".to_owned() - // ); - // - // //Number - // let number = NumberTypeOptionBuilder::default().set_format(NumberFormat::USD); - // let number_field_meta = FieldBuilder::new(number).build(); - // let data = TypeOptionCellData::new("18443", FieldType::Number).json(); - // assert_eq!( - // type_option.decode_cell_data(data, &number_field_meta), - // "$18,443".to_owned() - // ); - // } + #[test] + fn text_description_test() { + let type_option = RichTextTypeOption::default(); + + // date + let date_time_field_meta = FieldBuilder::from_field_type(&FieldType::DateTime).build(); + let data = TypeOptionCellData::new("1647251762", FieldType::DateTime).json(); + assert_eq!( + type_option.decode_cell_data(data, &date_time_field_meta), + "Mar 14,2022".to_owned() + ); + + // Single select + let done_option = SelectOption::new("Done"); + let done_option_id = done_option.id.clone(); + let single_select = SingleSelectTypeOptionBuilder::default().option(done_option); + let single_select_field_meta = FieldBuilder::new(single_select).build(); + let cell_data = TypeOptionCellData::new(&done_option_id, FieldType::SingleSelect).json(); + assert_eq!( + type_option.decode_cell_data(cell_data, &single_select_field_meta), + "Done".to_owned() + ); + + // Multiple select + let google_option = SelectOption::new("Google"); + let facebook_option = SelectOption::new("Facebook"); + let ids = vec![google_option.id.clone(), facebook_option.id.clone()].join(SELECTION_IDS_SEPARATOR); + let cell_data_changeset = SelectOptionCellChangeset::from_insert(&ids).cell_data(); + let multi_select = MultiSelectTypeOptionBuilder::default() + .option(google_option) + .option(facebook_option); + let multi_select_field_meta = FieldBuilder::new(multi_select).build(); + let multi_type_option = MultiSelectTypeOption::from(&multi_select_field_meta); + let cell_data = multi_type_option.apply_changeset(cell_data_changeset, None).unwrap(); + assert_eq!( + type_option.decode_cell_data(cell_data, &multi_select_field_meta), + "Google,Facebook".to_owned() + ); + + //Number + let number = NumberTypeOptionBuilder::default().set_format(NumberFormat::USD); + let number_field_meta = FieldBuilder::new(number).build(); + let data = TypeOptionCellData::new("18443", FieldType::Number).json(); + assert_eq!( + type_option.decode_cell_data(data, &number_field_meta), + "$18,443".to_owned() + ); + } } diff --git a/frontend/rust-lib/flowy-net/src/handlers/mod.rs b/frontend/rust-lib/flowy-net/src/handlers/mod.rs index bb2f58fb4c..3f77ba3a04 100644 --- a/frontend/rust-lib/flowy-net/src/handlers/mod.rs +++ b/frontend/rust-lib/flowy-net/src/handlers/mod.rs @@ -3,7 +3,7 @@ use flowy_error::FlowyError; use lib_dispatch::prelude::{AppData, Data}; use std::sync::Arc; -#[tracing::instrument(skip(data, ws_manager))] +#[tracing::instrument(level = "debug", skip(data, ws_manager))] pub async fn update_network_ty( data: Data, ws_manager: AppData>, diff --git a/frontend/rust-lib/flowy-sdk/src/lib.rs b/frontend/rust-lib/flowy-sdk/src/lib.rs index 33c94f9f0f..06a140805e 100644 --- a/frontend/rust-lib/flowy-sdk/src/lib.rs +++ b/frontend/rust-lib/flowy-sdk/src/lib.rs @@ -55,8 +55,8 @@ impl FlowySDKConfig { } } - pub fn log_filter(mut self, filter: &str) -> Self { - self.log_filter = crate_log_filter(filter.to_owned()); + pub fn log_filter(mut self, level: &str) -> Self { + self.log_filter = crate_log_filter(level.to_owned()); self } } @@ -69,12 +69,12 @@ fn crate_log_filter(level: String) -> String { filters.push(format!("flowy_user={}", level)); filters.push(format!("flowy_text_block={}", level)); filters.push(format!("flowy_grid={}", level)); - filters.push(format!("flowy_collaboration={}", "debug")); + filters.push(format!("flowy_collaboration={}", "info")); filters.push(format!("dart_notify={}", level)); filters.push(format!("lib_ot={}", level)); filters.push(format!("lib_ws={}", level)); filters.push(format!("lib_infra={}", level)); - filters.push(format!("flowy_sync={}", "debug")); + filters.push(format!("flowy_sync={}", level)); filters.push(format!("dart_ffi={}", "info")); filters.push(format!("flowy_database={}", "info")); diff --git a/frontend/rust-lib/flowy-test/src/lib.rs b/frontend/rust-lib/flowy-test/src/lib.rs index 1bd12ff9a1..70159edf19 100644 --- a/frontend/rust-lib/flowy-test/src/lib.rs +++ b/frontend/rust-lib/flowy-test/src/lib.rs @@ -36,7 +36,7 @@ impl std::default::Default for FlowySDKTest { impl FlowySDKTest { pub fn new(server_config: ClientServerConfiguration) -> Self { - let config = FlowySDKConfig::new(&root_dir(), server_config, &nanoid!(6)).log_filter("trace"); + let config = FlowySDKConfig::new(&root_dir(), server_config, &nanoid!(6)).log_filter("info"); let sdk = std::thread::spawn(|| FlowySDK::new(config)).join().unwrap(); std::mem::forget(sdk.dispatcher()); Self { inner: sdk } diff --git a/frontend/rust-lib/flowy-text-block/src/event_handler.rs b/frontend/rust-lib/flowy-text-block/src/event_handler.rs index 4e8b48ae05..183103b73e 100644 --- a/frontend/rust-lib/flowy-text-block/src/event_handler.rs +++ b/frontend/rust-lib/flowy-text-block/src/event_handler.rs @@ -27,7 +27,7 @@ pub(crate) async fn apply_delta_handler( data_result(block_delta) } -#[tracing::instrument(skip(data, manager), err)] +#[tracing::instrument(level = "debug", skip(data, manager), err)] pub(crate) async fn export_handler( data: Data, manager: AppData>, diff --git a/frontend/rust-lib/flowy-text-block/tests/editor/mod.rs b/frontend/rust-lib/flowy-text-block/tests/editor/mod.rs index f9ed7c72ac..f463a0932a 100644 --- a/frontend/rust-lib/flowy-text-block/tests/editor/mod.rs +++ b/frontend/rust-lib/flowy-text-block/tests/editor/mod.rs @@ -13,7 +13,7 @@ use lib_ot::{ use rand::{prelude::*, Rng as WrappedRng}; use std::{sync::Once, time::Duration}; -const LEVEL: &str = "debug"; +const LEVEL: &str = "info"; #[derive(Clone, Debug, Display)] pub enum TestOp { diff --git a/frontend/rust-lib/flowy-user/src/handlers/auth_handler.rs b/frontend/rust-lib/flowy-user/src/handlers/auth_handler.rs index 0285b2a442..b5d667bcbe 100644 --- a/frontend/rust-lib/flowy-user/src/handlers/auth_handler.rs +++ b/frontend/rust-lib/flowy-user/src/handlers/auth_handler.rs @@ -5,7 +5,7 @@ use lib_dispatch::prelude::*; use std::{convert::TryInto, sync::Arc}; // tracing instrument 👉🏻 https://docs.rs/tracing/0.1.26/tracing/attr.instrument.html -#[tracing::instrument(name = "sign_in", skip(data, session), fields(email = %data.email), err)] +#[tracing::instrument(level = "debug", name = "sign_in", skip(data, session), fields(email = %data.email), err)] pub async fn sign_in( data: Data, session: AppData>, @@ -16,6 +16,7 @@ pub async fn sign_in( } #[tracing::instrument( + level = "debug", name = "sign_up", skip(data, session), fields( diff --git a/frontend/rust-lib/flowy-user/src/handlers/user_handler.rs b/frontend/rust-lib/flowy-user/src/handlers/user_handler.rs index 1692faa9ac..a13f7187f7 100644 --- a/frontend/rust-lib/flowy-user/src/handlers/user_handler.rs +++ b/frontend/rust-lib/flowy-user/src/handlers/user_handler.rs @@ -6,31 +6,31 @@ use flowy_user_data_model::entities::{ use lib_dispatch::prelude::*; use std::{convert::TryInto, sync::Arc}; -#[tracing::instrument(skip(session))] +#[tracing::instrument(level = "debug", skip(session))] pub async fn init_user_handler(session: AppData>) -> Result<(), FlowyError> { let _ = session.init_user().await?; Ok(()) } -#[tracing::instrument(skip(session))] +#[tracing::instrument(level = "debug", skip(session))] pub async fn check_user_handler(session: AppData>) -> DataResult { let user_profile = session.check_user().await?; data_result(user_profile) } -#[tracing::instrument(skip(session))] +#[tracing::instrument(level = "debug", skip(session))] pub async fn get_user_profile_handler(session: AppData>) -> DataResult { let user_profile = session.user_profile().await?; data_result(user_profile) } -#[tracing::instrument(name = "sign_out", skip(session))] +#[tracing::instrument(level = "debug", name = "sign_out", skip(session))] pub async fn sign_out(session: AppData>) -> Result<(), FlowyError> { let _ = session.sign_out().await?; Ok(()) } -#[tracing::instrument(name = "update_user", skip(data, session))] +#[tracing::instrument(level = "debug", name = "update_user", skip(data, session))] pub async fn update_user_handler( data: Data, session: AppData>, @@ -42,7 +42,7 @@ pub async fn update_user_handler( const APPEARANCE_SETTING_CACHE_KEY: &str = "appearance_settings"; -#[tracing::instrument(skip(data), err)] +#[tracing::instrument(level = "debug", skip(data), err)] pub async fn set_appearance_setting(data: Data) -> Result<(), FlowyError> { let mut setting = data.into_inner(); if setting.theme.is_empty() { diff --git a/frontend/rust-lib/flowy-user/src/services/database.rs b/frontend/rust-lib/flowy-user/src/services/database.rs index 1229d6fba5..f3ddf48fa5 100644 --- a/frontend/rust-lib/flowy-user/src/services/database.rs +++ b/frontend/rust-lib/flowy-user/src/services/database.rs @@ -27,7 +27,7 @@ impl UserDB { return Err(ErrorCode::UserIdIsEmpty.into()); } - tracing::info!("open user db {}", user_id); + tracing::trace!("open user db {}", user_id); let dir = format!("{}/{}", self.db_dir, user_id); let db = flowy_database::init(&dir).map_err(|e| { log::error!("init user db failed, {:?}, user_id: {}", e, user_id); diff --git a/frontend/rust-lib/lib-log/src/lib.rs b/frontend/rust-lib/lib-log/src/lib.rs index c667f33344..d2e0310906 100644 --- a/frontend/rust-lib/lib-log/src/lib.rs +++ b/frontend/rust-lib/lib-log/src/lib.rs @@ -94,7 +94,7 @@ mod tests { say("hello world"); } - #[tracing::instrument(name = "say")] + #[tracing::instrument(level = "trace", name = "say")] fn say(s: &str) { tracing::info!("{}", s); }