Update debug-log (#236)

* chore: use new version of debug-log

* fix: rm group_end
This commit is contained in:
Zixuan Chen 2024-01-05 12:12:04 +08:00 committed by GitHub
parent 92305f8917
commit aaec64a503
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 27 additions and 55 deletions

4
Cargo.lock generated
View file

@ -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",

View file

@ -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" }

View file

@ -70,15 +70,12 @@ impl<T: ActorTrait> ActorGroup<T> {
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<T: ActorTrait> ActorGroup<T> {
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<T: ActorTrait>(
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();

View file

@ -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"

View file

@ -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]) {

View file

@ -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,

View file

@ -314,7 +314,7 @@ impl<'a, T: DagNode + 'a, D: Dag<Node = T>> 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));

View file

@ -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)

View file

@ -345,20 +345,16 @@ fn check_synced(sites: &mut [LoroDoc], _: &[Arc<Mutex<Delta<StringSlice, StyleMe
if (i + j) % 2 == 1 {
debug_log::group!("Import {}'s Snapshot to {}", j, i);
a.import(&b.export_snapshot()).unwrap();
debug_log::group_end!();
} else {
debug_log::group!("Import {} to {}", j, i);
a.import(&b.export_from(&a.oplog_vv())).unwrap();
debug_log::group_end!();
}
}
{
debug_log::group!("Import {} to {}", i, j);
b.import(&a.export_from(&b.oplog_vv())).unwrap();
debug_log::group_end!();
}
check_eq(a, b);
debug_log::group_end!();
// for (x, (site, text)) in sites.iter().zip(texts.iter()).enumerate() {
// if x != i && x != j {
@ -376,7 +372,7 @@ fn check_synced(sites: &mut [LoroDoc], _: &[Arc<Mutex<Delta<StringSlice, StyleMe
// "site:{}\nEXPECTED {:#?}\nACTUAL {:#?}",
// x, diff, text
// );
// debug_log::group_end!();
//
// }
}
}
@ -546,7 +542,6 @@ pub fn test_multi_sites(site_num: u8, actions: &mut [Action]) {
debug_log!("\n{}", (&applied).table());
debug_log::group!("ApplyAction {:?}", &action);
sites.apply_action(action);
debug_log::group_end!();
// for (i, (site, text)) in sites.iter().zip(texts.iter()).enumerate() {
// debug_log::group!("Check {}", i);
@ -560,14 +555,14 @@ pub fn test_multi_sites(site_num: u8, actions: &mut [Action]) {
// "site:{}\nEXPECTED{:#?}\nACTUAL{:#?}",
// i, diff, text
// );
// debug_log::group_end!();
//
// }
}
debug_log::group!("CheckSynced");
// println!("{}", actions.table());
check_synced(&mut sites, &texts);
debug_log::group_end!();
debug_log::group!("CheckTextEvent");
for (i, (site, text)) in sites.iter().zip(texts.iter()).enumerate() {
debug_log::group!("Check {}", i);
@ -583,10 +578,7 @@ pub fn test_multi_sites(site_num: u8, actions: &mut [Action]) {
"site:{}\nEXPECTED{:#?}\nACTUAL{:#?}",
i, diff, text
);
debug_log::group_end!();
}
debug_log::group_end!();
}
pub fn compact(delta: &mut Delta<StringSlice, StyleMeta>) {

View file

@ -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]);
}

View file

@ -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)]

View file

@ -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]);
}

View file

@ -453,7 +453,6 @@ impl TextHandler {
event_end = event_start;
}
debug_log::group_end!();
Ok(())
}

View file

@ -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);
}
}

View file

@ -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)
}

View file

@ -503,7 +503,6 @@ impl ContainerState for RichtextState {
encoder.encode_op(id_span, || unimplemented!());
}
debug_log::group_end!();
lamports.encode()
}

View file

@ -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();

View file

@ -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" }

View file

@ -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]