diff --git a/src/function/maybe_changed_after.rs b/src/function/maybe_changed_after.rs index e81119e8..56f1ab70 100644 --- a/src/function/maybe_changed_after.rs +++ b/src/function/maybe_changed_after.rs @@ -72,6 +72,7 @@ where tracing::debug!( "{database_key_index:?}: maybe_changed_after_cold, successful claim, \ revision = {revision:?}, old_memo = {old_memo:#?}", + old_memo = old_memo.tracing_debug() ); // Check if the inputs are still valid and we can just compare `changed_at`. @@ -105,7 +106,10 @@ where let verified_at = memo.verified_at.load(); let revision_now = zalsa.current_revision(); - tracing::debug!("{database_key_index:?}: shallow_verify_memo(memo = {memo:#?})",); + tracing::debug!( + "{database_key_index:?}: shallow_verify_memo(memo = {memo:#?})", + memo = memo.tracing_debug() + ); if verified_at == revision_now { // Already verified. @@ -140,7 +144,10 @@ where let zalsa = db.zalsa(); let database_key_index = active_query.database_key_index; - tracing::debug!("{database_key_index:?}: deep_verify_memo(old_memo = {old_memo:#?})",); + tracing::debug!( + "{database_key_index:?}: deep_verify_memo(old_memo = {old_memo:#?})", + old_memo = old_memo.tracing_debug() + ); if self.shallow_verify_memo(db, zalsa, database_key_index, old_memo) { return true; diff --git a/src/function/memo.rs b/src/function/memo.rs index 22b97bdc..31ae91ff 100644 --- a/src/function/memo.rs +++ b/src/function/memo.rs @@ -1,3 +1,4 @@ +use std::fmt::Formatter; use std::sync::Arc; use arc_swap::{ArcSwap, Guard}; @@ -168,4 +169,29 @@ impl Memo { output.mark_validated_output(db, database_key_index); } } + + pub(super) fn tracing_debug(&self) -> impl std::fmt::Debug + '_ { + struct TracingDebug<'a, T> { + memo: &'a Memo, + } + + impl std::fmt::Debug for TracingDebug<'_, T> { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + f.debug_struct("Memo") + .field( + "value", + if self.memo.value.is_some() { + &"Some()" + } else { + &"None" + }, + ) + .field("verified_at", &self.memo.verified_at) + .field("revisions", &self.memo.revisions) + .finish() + } + } + + TracingDebug { memo: self } + } } diff --git a/src/function/specify.rs b/src/function/specify.rs index 94d7a287..9aabac54 100644 --- a/src/function/specify.rs +++ b/src/function/specify.rs @@ -81,7 +81,11 @@ where revisions, }; - tracing::debug!("specify: about to add memo {:#?} for key {:?}", memo, key); + tracing::debug!( + "specify: about to add memo {:#?} for key {:?}", + memo.tracing_debug(), + key + ); self.insert_memo(db, key, memo); // Record that the current query *specified* a value for this cell.