diff --git a/Cargo.lock b/Cargo.lock index 244ec6bf..5f7a22b8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -423,9 +423,9 @@ dependencies = [ [[package]] name = "debug-log" -version = "0.2.2" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b90f9d9c0c144c4aa35a874e362392ec6aef3b9291c882484235069540b26c73" +checksum = "9ee1f7e4702f35f9add609068329609a6349e7ace9804a2386a1cadb0c609d63" dependencies = [ "once_cell", "wasm-bindgen", diff --git a/crates/examples/Cargo.toml b/crates/examples/Cargo.toml index 8a1ec485..60c3811d 100644 --- a/crates/examples/Cargo.toml +++ b/crates/examples/Cargo.toml @@ -10,7 +10,7 @@ bench-utils = { path = "../bench-utils" } loro = { path = "../loro" } tabled = "0.15.0" arbitrary = { version = "1.3.0", features = ["derive"] } -debug-log = { version = "0.2", features = [] } +debug-log = { version = "0.3", features = [] } [dev-dependencies] color-backtrace = { version = "0.6" } diff --git a/crates/examples/src/lib.rs b/crates/examples/src/lib.rs index 4b1684da..8842ec25 100644 --- a/crates/examples/src/lib.rs +++ b/crates/examples/src/lib.rs @@ -70,15 +70,12 @@ impl ActorGroup { debug_log::group!("Importing to doc0"); let vv = first[0].doc().oplog_vv(); first[0].doc().import(&doc.doc().export_from(&vv)).unwrap(); - debug_log::group_end!(); } for (i, doc) in rest.iter_mut().enumerate() { debug_log::group!("Importing to doc{}", i + 1); let vv = doc.doc().oplog_vv(); doc.doc().import(&first[0].doc().export_from(&vv)).unwrap(); - debug_log::group_end!(); } - debug_log::group_end!(); } pub fn check_sync(&self) { @@ -88,7 +85,6 @@ impl ActorGroup { for doc in self.docs.iter().skip(1) { assert_eq!(content, doc.doc().get_deep_value()); } - debug_log::group_end!(); } } @@ -149,7 +145,6 @@ pub fn run_actions_fuzz_in_async_mode( for action in actions.iter_mut() { debug_log::group!("[ApplyAction] {:?}", &action); actors.apply_action(action); - debug_log::group_end!(); } actors.sync_all(); actors.check_sync(); diff --git a/crates/loro-internal/Cargo.toml b/crates/loro-internal/Cargo.toml index 497d468c..493e2c38 100644 --- a/crates/loro-internal/Cargo.toml +++ b/crates/loro-internal/Cargo.toml @@ -26,7 +26,7 @@ serde-wasm-bindgen = { version = "0.5.0", optional = true } js-sys = { version = "0.3.60", optional = true } serde_json = { version = "1" } arref = "0.1.0" -debug-log = { version = "0.2.2", features = [] } +debug-log = { version = "0.3", features = [] } serde_columnar = { version = "0.3.3" } append-only-bytes = { version = "0.1.12", features = ["u32_range"] } itertools = "0.11.0" diff --git a/crates/loro-internal/src/container/richtext/tracker.rs b/crates/loro-internal/src/container/richtext/tracker.rs index 4fb0cb34..382026e5 100644 --- a/crates/loro-internal/src/container/richtext/tracker.rs +++ b/crates/loro-internal/src/container/richtext/tracker.rs @@ -129,7 +129,7 @@ impl Tracker { self.current_vv.extend_to_include_end_id(end_id); self.applied_vv.extend_to_include_end_id(end_id); // debug_log::debug_dbg!(&self); - // debug_log::group_end!(); + // } fn update_insert_by_split(&mut self, split: &[LeafIndex]) { diff --git a/crates/loro-internal/src/container/richtext/tracker/crdt_rope.rs b/crates/loro-internal/src/container/richtext/tracker/crdt_rope.rs index c69c9403..eeaf3af7 100644 --- a/crates/loro-internal/src/container/richtext/tracker/crdt_rope.rs +++ b/crates/loro-internal/src/container/richtext/tracker/crdt_rope.rs @@ -215,7 +215,7 @@ impl CrdtRope { } // debug_log::debug_log!("Inserting at {:?}", insert_pos); - // debug_log::group_end!(); + // let (cursor, splitted) = self.tree.insert_by_path(insert_pos, content); InsertResult { content, diff --git a/crates/loro-internal/src/dag/iter.rs b/crates/loro-internal/src/dag/iter.rs index d2a11b93..3dbd0e18 100644 --- a/crates/loro-internal/src/dag/iter.rs +++ b/crates/loro-internal/src/dag/iter.rs @@ -314,7 +314,7 @@ impl<'a, T: DagNode + 'a, D: Dag> Iterator for DagCausalIter<'a, D> { // debug_log::group!("Dag Causal"); // debug_log::debug_dbg!(&deps); // debug_log::debug_dbg!(&path); - // debug_log::group_end!(); + // // NOTE: we expect user to update the tracker, to apply node, after visiting the node self.frontier = Frontiers::from_id(node.id_start().inc(slice_end - 1)); diff --git a/crates/loro-internal/src/diff_calc.rs b/crates/loro-internal/src/diff_calc.rs index 9b2eef0e..142b6aad 100644 --- a/crates/loro-internal/src/diff_calc.rs +++ b/crates/loro-internal/src/diff_calc.rs @@ -306,8 +306,6 @@ impl DiffCalculator { } } - debug_log::group_end!(); - // debug_log::debug_dbg!(&ans); ans.into_values() .sorted_by_key(|x| x.0) .map(|x| x.1) diff --git a/crates/loro-internal/src/fuzz.rs b/crates/loro-internal/src/fuzz.rs index a840d3de..975a4484 100644 --- a/crates/loro-internal/src/fuzz.rs +++ b/crates/loro-internal/src/fuzz.rs @@ -345,20 +345,16 @@ fn check_synced(sites: &mut [LoroDoc], _: &[Arc) { diff --git a/crates/loro-internal/src/fuzz/recursive_refactored.rs b/crates/loro-internal/src/fuzz/recursive_refactored.rs index 333f8e2a..ba408671 100644 --- a/crates/loro-internal/src/fuzz/recursive_refactored.rs +++ b/crates/loro-internal/src/fuzz/recursive_refactored.rs @@ -757,21 +757,19 @@ fn check_synced(sites: &mut [Actor]) { if (i + j) % 2 == 0 { debug_log::group!("Updates {} to {}", j, i); a_doc.import(&b_doc.export_from(&a_doc.oplog_vv())).unwrap(); - debug_log::group_end!(); + debug_log::group!("Updates {} to {}", i, j); b_doc.import(&a_doc.export_from(&b_doc.oplog_vv())).unwrap(); - debug_log::group_end!(); } else { debug_log::group!("Snapshot {} to {}", j, i); a_doc.import(&b_doc.export_snapshot()).unwrap(); - debug_log::group_end!(); + debug_log::group!("Snapshot {} to {}", i, j); b_doc.import(&a_doc.export_snapshot()).unwrap(); - debug_log::group_end!(); } check_eq(a, b); - debug_log::group_end!(); + if i == 1 { a.record_history(); } @@ -795,7 +793,6 @@ fn check_history(actor: &mut Actor) { let actual = actor.loro.get_deep_value(); assert_value_eq(v, &actual); assert_value_eq(v, &actor.value_tracker.lock().unwrap()); - debug_log::group_end!(); } } @@ -842,7 +839,7 @@ pub fn test_multi_sites(site_num: u8, actions: &mut [Action]) { debug_log::group!("check synced"); check_synced(&mut sites); - debug_log::group_end!(); + check_history(&mut sites[1]); } diff --git a/crates/loro-internal/src/fuzz/richtext.rs b/crates/loro-internal/src/fuzz/richtext.rs index c3a5c6fa..962b349a 100644 --- a/crates/loro-internal/src/fuzz/richtext.rs +++ b/crates/loro-internal/src/fuzz/richtext.rs @@ -484,20 +484,18 @@ fn check_synced(sites: &mut [Actor]) { if (i + j) % 2 == 0 { debug_log::group!("Updates {} to {}", j, i); a_doc.import(&b_doc.export_from(&a_doc.oplog_vv())).unwrap(); - debug_log::group_end!(); + debug_log::group!("Updates {} to {}", i, j); b_doc.import(&a_doc.export_from(&b_doc.oplog_vv())).unwrap(); - debug_log::group_end!(); } else { debug_log::group!("Snapshot {} to {}", j, i); a_doc.import(&b_doc.export_snapshot()).unwrap(); - debug_log::group_end!(); + debug_log::group!("Snapshot {} to {}", i, j); b_doc.import(&a_doc.export_snapshot()).unwrap(); - debug_log::group_end!(); } check_eq(a, b); - debug_log::group_end!(); + if i == 1 { a.record_history(); } @@ -558,12 +556,11 @@ pub fn test_multi_sites(site_num: u8, actions: &mut [Action]) { debug_log::debug_log!("\n{}", (&applied).table()); debug_log::group!("ApplyingAction={:?}", &action); sites.apply_action(action); - debug_log::group_end!(); } debug_log::group!("check synced"); check_synced(&mut sites); - debug_log::group_end!(); + check_history(&mut sites[1]); } #[cfg(test)] diff --git a/crates/loro-internal/src/fuzz/tree.rs b/crates/loro-internal/src/fuzz/tree.rs index 263f5a09..c5782723 100644 --- a/crates/loro-internal/src/fuzz/tree.rs +++ b/crates/loro-internal/src/fuzz/tree.rs @@ -668,20 +668,18 @@ fn check_synced(sites: &mut [Actor]) { if (i + j) % 2 == 0 { debug_log::group!("Updates {} to {}", j, i); a_doc.import(&b_doc.export_from(&a_doc.oplog_vv())).unwrap(); - debug_log::group_end!(); + debug_log::group!("Updates {} to {}", i, j); b_doc.import(&a_doc.export_from(&b_doc.oplog_vv())).unwrap(); - debug_log::group_end!(); } else { debug_log::group!("Snapshot {} to {}", j, i); a_doc.import(&b_doc.export_snapshot()).unwrap(); - debug_log::group_end!(); + debug_log::group!("Snapshot {} to {}", i, j); b_doc.import(&a_doc.export_snapshot()).unwrap(); - debug_log::group_end!(); } check_eq(a, b); - debug_log::group_end!(); + if i == 1 { a.record_history(); } @@ -758,7 +756,7 @@ pub fn test_multi_sites(site_num: u8, actions: &mut [Action]) { debug_log::group!("check synced"); check_synced(&mut sites); - debug_log::group_end!(); + check_history(&mut sites[1]); } diff --git a/crates/loro-internal/src/handler.rs b/crates/loro-internal/src/handler.rs index 0cbe87b8..70ae4e3c 100644 --- a/crates/loro-internal/src/handler.rs +++ b/crates/loro-internal/src/handler.rs @@ -453,7 +453,6 @@ impl TextHandler { event_end = event_start; } - debug_log::group_end!(); Ok(()) } diff --git a/crates/loro-internal/src/loro.rs b/crates/loro-internal/src/loro.rs index 3f1cda49..bd4431a9 100644 --- a/crates/loro-internal/src/loro.rs +++ b/crates/loro-internal/src/loro.rs @@ -386,7 +386,6 @@ impl LoroDoc { |oplog| oplog.decode(parsed), origin, )?; - debug_log::group_end!(); } true => { if self.can_reset_with_snapshot() { @@ -406,7 +405,7 @@ impl LoroDoc { // TODO: PERF: the ser and de can be optimized out let updates = app.export_from(oplog.vv()); drop(oplog); - debug_log::group_end!(); + return self.import_with(&updates, origin); } } diff --git a/crates/loro-internal/src/state.rs b/crates/loro-internal/src/state.rs index 89e13dce..60970852 100644 --- a/crates/loro-internal/src/state.rs +++ b/crates/loro-internal/src/state.rs @@ -829,7 +829,6 @@ impl DocState { if let Some(parent_idx) = self.arena.get_parent(idx) { let parent_state = self.states.get(&parent_idx).unwrap(); let Some(prop) = parent_state.get_child_index(&id) else { - debug_log::group_end!(); return None; }; ans.push((id, prop)); @@ -843,7 +842,7 @@ impl DocState { } ans.reverse(); - debug_log::group_end!(); + Some(ans) } diff --git a/crates/loro-internal/src/state/richtext_state.rs b/crates/loro-internal/src/state/richtext_state.rs index 96c26123..51641df0 100644 --- a/crates/loro-internal/src/state/richtext_state.rs +++ b/crates/loro-internal/src/state/richtext_state.rs @@ -503,7 +503,6 @@ impl ContainerState for RichtextState { encoder.encode_op(id_span, || unimplemented!()); } - debug_log::group_end!(); lamports.encode() } diff --git a/crates/loro-internal/tests/test.rs b/crates/loro-internal/tests/test.rs index f4cca49b..7a1af293 100644 --- a/crates/loro-internal/tests/test.rs +++ b/crates/loro-internal/tests/test.rs @@ -9,7 +9,6 @@ use loro_internal::{ }; use serde_json::json; - #[test] fn issue_225() -> LoroResult<()> { let doc = LoroDoc::new_auto_commit(); @@ -681,7 +680,7 @@ fn a_list_of_map_checkout() { assert_eq!(doc.get_deep_value().to_json(), d2); debug_log::group!("checking out v1"); doc.checkout(&v1).unwrap(); - debug_log::group_end!(); + println!("{}", doc.get_deep_value_with_id().to_json_pretty()); assert_eq!(doc.get_deep_value().to_json(), d1); doc.checkout(&v0).unwrap(); diff --git a/crates/loro-wasm/Cargo.toml b/crates/loro-wasm/Cargo.toml index 28e71ff0..d9f92177 100644 --- a/crates/loro-wasm/Cargo.toml +++ b/crates/loro-wasm/Cargo.toml @@ -13,7 +13,7 @@ wasm-bindgen = "=0.2.86" serde-wasm-bindgen = { version = "0.5.0" } console_error_panic_hook = { version = "0.1.6", optional = true } getrandom = { version = "0.2.10", features = ["js"] } -debug-log = { version = "0.2.2", features = ["wasm"] } +debug-log = { version = "0.3", features = ["wasm"] } serde = { version = "1", features = ["derive"] } rle = { path = "../rle", package = "loro-rle" } diff --git a/crates/rle/Cargo.toml b/crates/rle/Cargo.toml index 8cb066bb..da2a3312 100644 --- a/crates/rle/Cargo.toml +++ b/crates/rle/Cargo.toml @@ -13,7 +13,7 @@ num = "0.4.0" enum-as-inner = "0.6.0" arref = "0.1.0" fxhash = "0.2.1" -debug-log = "0.2.2" +debug-log = "0.3" append-only-bytes = { version = "0.1.11", features = ["u32_range"] } [dev-dependencies]