diff --git a/packages/rs-drive/src/util/grove_operations/grove_apply_batch_with_add_costs/v0/mod.rs b/packages/rs-drive/src/util/grove_operations/grove_apply_batch_with_add_costs/v0/mod.rs index 4d024ecc436..09a5ec9206e 100644 --- a/packages/rs-drive/src/util/grove_operations/grove_apply_batch_with_add_costs/v0/mod.rs +++ b/packages/rs-drive/src/util/grove_operations/grove_apply_batch_with_add_costs/v0/mod.rs @@ -84,26 +84,32 @@ impl Drive { ); #[cfg(feature = "grovedb_operations_logging")] - if tracing::event_enabled!(target: "drive_grovedb_operations", tracing::Level::TRACE) - && cost_context.value.is_ok() - { - let root_hash = self - .grove - .root_hash(transaction, &drive_version.grove_version) - .unwrap() - .map_err(Error::from)?; - - let (ops, previous_root_hash) = - maybe_params_for_logs.expect("log params should be set above"); - - tracing::trace!( - target: "drive_grovedb_operations", - ?ops, - ?root_hash, - ?previous_root_hash, - is_transactional = transaction.is_some(), - "grovedb batch applied", - ); + if let Some((ops, previous_root_hash)) = maybe_params_for_logs { + if cost_context.value.is_ok() { + match self + .grove + .root_hash(transaction, &drive_version.grove_version) + .unwrap() + { + Ok(root_hash) => { + tracing::trace!( + target: "drive_grovedb_operations", + ?ops, + ?root_hash, + ?previous_root_hash, + is_transactional = transaction.is_some(), + "grovedb batch applied", + ); + } + Err(e) => { + tracing::warn!( + target: "drive_grovedb_operations", + error = ?e, + "failed to get root hash for post-batch logging", + ); + } + } + } } push_drive_operation_result(cost_context, drive_operations) diff --git a/packages/rs-drive/src/util/grove_operations/grove_clear/v0/mod.rs b/packages/rs-drive/src/util/grove_operations/grove_clear/v0/mod.rs index ac452ab152f..628bd0a1d80 100644 --- a/packages/rs-drive/src/util/grove_operations/grove_clear/v0/mod.rs +++ b/packages/rs-drive/src/util/grove_operations/grove_clear/v0/mod.rs @@ -47,26 +47,32 @@ impl Drive { .map(|_| ()); #[cfg(feature = "grovedb_operations_logging")] - if tracing::event_enabled!(target: "drive_grovedb_operations", tracing::Level::TRACE) - && result.is_ok() - { - let root_hash = self - .grove - .root_hash(transaction, &drive_version.grove_version) - .unwrap() - .map_err(Error::from)?; - - let (path, previous_root_hash) = - maybe_params_for_logs.expect("log params should be set above"); - - tracing::trace!( - target: "drive_grovedb_operations", - path = ?path.to_vec(), - ?root_hash, - ?previous_root_hash, - is_transactional = transaction.is_some(), - "grovedb clear", - ); + if let Some((path, previous_root_hash)) = maybe_params_for_logs { + if result.is_ok() { + match self + .grove + .root_hash(transaction, &drive_version.grove_version) + .unwrap() + { + Ok(root_hash) => { + tracing::trace!( + target: "drive_grovedb_operations", + path = ?path.to_vec(), + ?root_hash, + ?previous_root_hash, + is_transactional = transaction.is_some(), + "grovedb clear", + ); + } + Err(e) => { + tracing::warn!( + target: "drive_grovedb_operations", + error = ?e, + "failed to get root hash for post-clear logging", + ); + } + } + } } result