config af log filter

This commit is contained in:
appflowy
2022-01-09 15:13:45 +08:00
parent 7e7254b306
commit 08a43c03d4
26 changed files with 74 additions and 46 deletions

View File

@ -130,13 +130,11 @@ impl CoreContext {
return Ok(());
}
}
tracing::debug!("Start initializing flowy core");
INIT_WORKSPACE.write().insert(token.to_owned(), true);
let _ = self.workspace_controller.init()?;
let _ = self.app_controller.init()?;
let _ = self.view_controller.init()?;
let _ = self.trash_controller.init()?;
tracing::debug!("Finish initializing core");
Ok(())
}

View File

@ -18,6 +18,7 @@ use tokio::sync::{mpsc, mpsc::UnboundedSender, oneshot};
pub struct ClientDocumentEditor {
pub doc_id: String,
#[allow(dead_code)]
rev_manager: Arc<DocumentRevisionManager>,
ws_manager: Arc<dyn DocumentWebSocketManager>,
edit_queue: UnboundedSender<EditorCommand>,

View File

@ -58,7 +58,7 @@ impl EditorCommandQueue {
.await;
}
#[tracing::instrument(level = "debug", skip(self), err)]
#[tracing::instrument(level = "trace", skip(self), err)]
async fn handle_command(&self, command: EditorCommand) -> Result<(), FlowyError> {
match command {
EditorCommand::ComposeLocalDelta { delta, ret } => {
@ -289,6 +289,7 @@ pub(crate) enum EditorCommand {
ReadDoc {
ret: Ret<String>,
},
#[allow(dead_code)]
ReadDocDelta {
ret: Ret<RichTextDelta>,
},

View File

@ -109,7 +109,7 @@ impl DocumentRevisionCache {
}
#[tracing::instrument(level = "debug", skip(self, doc_id, revisions))]
pub async fn reset_document(&self, doc_id: &str, revisions: Vec<Revision>) -> FlowyResult<()> {
pub async fn reset_with_revisions(&self, doc_id: &str, revisions: Vec<Revision>) -> FlowyResult<()> {
let revision_records = revisions
.to_vec()
.into_iter()

View File

@ -120,7 +120,11 @@ impl RevisionTableSql {
.filter(dsl::rev_id.eq(changeset.rev_id.as_ref()))
.filter(dsl::doc_id.eq(changeset.doc_id));
let _ = update(filter).set(dsl::state.eq(changeset.state)).execute(conn)?;
tracing::debug!("Save revision:{} state to {:?}", changeset.rev_id, changeset.state);
tracing::debug!(
"[[RevisionTable]] Save:{} state to {:?}",
changeset.rev_id,
changeset.state
);
Ok(())
}
@ -170,7 +174,7 @@ impl RevisionTableSql {
}
let affected_row = sql.execute(conn)?;
tracing::debug!("Delete {} revision rows", affected_row);
tracing::trace!("[RevisionTable] Delete {} rows", affected_row);
Ok(())
}
}

View File

@ -60,7 +60,10 @@ impl DocumentRevisionManager {
#[tracing::instrument(level = "debug", skip(self, revisions), err)]
pub async fn reset_document(&self, revisions: RepeatedRevision) -> FlowyResult<()> {
let rev_id = pair_rev_id_from_revisions(&revisions).1;
let _ = self.cache.reset_document(&self.doc_id, revisions.into_inner()).await?;
let _ = self
.cache
.reset_with_revisions(&self.doc_id, revisions.into_inner())
.await?;
self.rev_id_counter.set(rev_id);
Ok(())
}

View File

@ -181,7 +181,7 @@ impl DocumentWSStream {
.await
.map_err(internal_error)?;
tracing::debug!("[DocumentStream]: new message: {:?}", ty);
tracing::trace!("[DocumentStream]: new message: {:?}", ty);
match ty {
DocumentServerWSDataType::ServerPushRev => {
let _ = self.consumer.receive_push_revision(bytes).await?;
@ -272,7 +272,7 @@ impl DocumentWSSink {
Ok(())
},
Some(data) => {
tracing::debug!("[DocumentSink]: send: {}:{}-{:?}", data.doc_id, data.id(), data.ty);
tracing::trace!("[DocumentSink]: send: {}:{}-{:?}", data.doc_id, data.id(), data.ty);
self.ws_sender.send(data)
// let _ = tokio::time::timeout(Duration::from_millis(2000),
},

View File

@ -55,6 +55,18 @@ async fn document_sync_insert_in_chinese() {
EditorTest::new().await.run_scripts(scripts).await;
}
#[tokio::test]
async fn document_sync_insert_with_emoji() {
let s = "😁".to_owned();
let offset = count_utf16_code_units(&s);
let scripts = vec![
InsertText("😁", 0),
InsertText("☺️", offset),
AssertJson(r#"[{"insert":"😁☺️\n"}]"#),
];
EditorTest::new().await.run_scripts(scripts).await;
}
#[tokio::test]
async fn document_sync_delete_in_english() {
let scripts = vec![

View File

@ -40,7 +40,7 @@ impl LocalDocumentServer {
client_data: DocumentClientWSData,
user_id: String,
) -> Result<(), CollaborateError> {
tracing::debug!(
tracing::trace!(
"[LocalDocumentServer] receive: {}:{}-{:?} ",
client_data.doc_id,
client_data.id(),
@ -72,7 +72,7 @@ struct LocalDocServerPersistence {
}
impl Debug for LocalDocServerPersistence {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { f.write_str("MockDocServerPersistence") }
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { f.write_str("LocalDocServerPersistence") }
}
impl std::default::Default for LocalDocServerPersistence {
@ -89,10 +89,7 @@ impl DocumentPersistence for LocalDocServerPersistence {
let doc_id = doc_id.to_owned();
Box::pin(async move {
match inner.get(&doc_id) {
None => {
//
Err(CollaborateError::record_not_found())
},
None => Err(CollaborateError::record_not_found()),
Some(val) => {
//
Ok(val.value().clone())

View File

@ -53,19 +53,19 @@ impl FlowySDKConfig {
FlowySDKConfig {
name: name.to_owned(),
root: root.to_owned(),
log_filter: crate_log_filter(None),
log_filter: crate_log_filter("info".to_owned()),
server_config,
}
}
pub fn log_filter(mut self, filter: &str) -> Self {
self.log_filter = crate_log_filter(Some(filter.to_owned()));
self.log_filter = crate_log_filter(filter.to_owned());
self
}
}
fn crate_log_filter(level: Option<String>) -> String {
let level = level.unwrap_or_else(|| std::env::var("RUST_LOG").unwrap_or_else(|_| "info".to_owned()));
fn crate_log_filter(level: String) -> String {
let level = std::env::var("RUST_LOG").unwrap_or(level);
let mut filters = vec![];
filters.push(format!("flowy_sdk={}", level));
filters.push(format!("flowy_core={}", level));
@ -73,6 +73,8 @@ fn crate_log_filter(level: Option<String>) -> String {
filters.push(format!("flowy_document={}", level));
filters.push(format!("flowy_collaboration={}", level));
filters.push(format!("flowy_net={}", level));
filters.push(format!("dart_ffi={}", "info"));
filters.push(format!("dart_database={}", "info"));
filters.push(format!("dart_notify={}", level));
filters.push(format!("lib_ot={}", level));
filters.push(format!("lib_ws={}", level));

View File

@ -34,7 +34,7 @@ impl std::default::Default for FlowySDKTest {
impl FlowySDKTest {
pub fn new(server_config: ClientServerConfiguration) -> Self {
let config = FlowySDKConfig::new(&root_dir(), server_config, &uuid_string()).log_filter("debug");
let config = FlowySDKConfig::new(&root_dir(), server_config, &uuid_string()).log_filter("trace");
let sdk = FlowySDK::new(config);
std::mem::forget(sdk.dispatcher());
Self { inner: sdk }