Add brain debug trace

main
mat ess 2023-03-03 00:54:12 -05:00
parent 2576f4c48a
commit 410740ea21
1 changed files with 5 additions and 4 deletions

View File

@ -31,13 +31,14 @@ impl Data {
.create(true)
.open(&path)
.await?;
let mut content = String::new();
file.read_to_string(&mut content).await?;
let brain = if content.is_empty() {
let mut contents = String::new();
file.read_to_string(&mut contents).await?;
tracing::debug!("loaded brain contents: {contents}");
let brain = if contents.is_empty() {
tracing::info!("initializing brain at {}", path.as_ref().display());
Default::default()
} else {
let brain = ron::from_str(content.as_str())?;
let brain = ron::from_str(contents.as_str())?;
tracing::info!("loaded brain from {}", path.as_ref().display());
Mutex::new(brain)
};