Minor improvements to layout_debug and associated code

This commit is contained in:
Fernando Jiménez Moreno 2020-02-21 16:34:32 +01:00
parent c33a517387
commit 5e76c93cc7
2 changed files with 19 additions and 50 deletions

View file

@ -8,8 +8,7 @@
use crate::flow::{BoxTreeRoot, FragmentTreeRoot};
use serde_json::{to_string, to_value, Value};
use std::cell::RefCell;
use std::fs::File;
use std::io::Write;
use std::fs;
#[cfg(debug_assertions)]
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc;
@ -141,6 +140,9 @@ pub fn end_trace(generation: u32) {
fragment_tree: to_value(&thread_state.fragment_tree).unwrap_or(Value::Null),
};
let result = to_string(&root_scope).unwrap();
let mut file = File::create(format!("layout_trace-{}.json", generation)).unwrap();
file.write_all(result.as_bytes()).unwrap();
fs::write(
format!("layout_trace-{}.json", generation),
result.as_bytes(),
)
.unwrap();
}