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) .create(true)
.open(&path) .open(&path)
.await?; .await?;
let mut content = String::new(); let mut contents = String::new();
file.read_to_string(&mut content).await?; file.read_to_string(&mut contents).await?;
let brain = if content.is_empty() { tracing::debug!("loaded brain contents: {contents}");
let brain = if contents.is_empty() {
tracing::info!("initializing brain at {}", path.as_ref().display()); tracing::info!("initializing brain at {}", path.as_ref().display());
Default::default() Default::default()
} else { } 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()); tracing::info!("loaded brain from {}", path.as_ref().display());
Mutex::new(brain) Mutex::new(brain)
}; };