From 052b252173507fca07b622ddec33fa2417692ae3 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 27 Sep 2026 20:48:35 +0200 Subject: feat(engine): improve & add fields to logs in Assets fns --- engine/src/asset.rs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'engine/src/asset.rs') diff --git a/engine/src/asset.rs b/engine/src/asset.rs index 781ca22..75b8592 100644 --- a/engine/src/asset.rs +++ b/engine/src/asset.rs @@ -170,7 +170,7 @@ impl Assets #[tracing::instrument( skip_all, - fields(asset_label, asset_type = type_name::()) + fields(asset_label, asset_type = %type_name::()) )] pub fn get(&self, handle: &Handle) -> Option<&AssetT> where @@ -201,7 +201,7 @@ impl Assets Some(asset) } - #[tracing::instrument(skip_all, fields(asset_type=type_name::()))] + #[tracing::instrument(skip_all, fields(label, asset_type = %type_name::()))] pub fn get_handle_to_loaded<'label, AssetT>( &self, label: impl Into>, @@ -211,6 +211,8 @@ impl Assets { let label = label.into(); + tracing::Span::current().record("label", tracing::field::display(&label)); + let label_hash = LabelHash::new(&label); let asset_lookup = self.asset_lookup.borrow(); @@ -282,13 +284,15 @@ impl Assets Some(label) } - #[tracing::instrument(skip(self))] - pub fn load<'i, AssetT>(&self, label: impl Into> + Debug) -> Handle + #[tracing::instrument(skip_all, fields(label, asset_type = %type_name::()))] + pub fn load<'i, AssetT>(&self, label: impl Into>) -> Handle where AssetT: Asset, { let label = label.into(); + tracing::Span::current().record("label", tracing::field::display(&label)); + let label_hash = LabelHash::new(&label); let mut asset_lookup = self.asset_lookup.borrow_mut(); @@ -324,7 +328,7 @@ impl Assets Handle::new(label_hash) } - #[tracing::instrument(skip(self))] + #[tracing::instrument(skip_all, fields(label, asset_type = %type_name::()))] pub fn load_with_settings<'i, AssetT, AssetSettings>( &self, label: impl Into> + Debug, @@ -336,6 +340,8 @@ impl Assets { let label = label.into(); + tracing::Span::current().record("label", tracing::field::display(&label)); + let label_hash = LabelHash::new(&label); let mut asset_lookup = self.asset_lookup.borrow_mut(); @@ -410,10 +416,10 @@ impl Assets ) } - #[tracing::instrument(skip(self, asset), fields(asset_type=type_name::()))] + #[tracing::instrument(skip_all, fields(label, asset_type = %type_name::()))] pub fn store_with_label<'i, AssetT>( &mut self, - label: impl Into> + Debug, + label: impl Into>, asset: AssetT, ) -> Handle where @@ -421,6 +427,8 @@ impl Assets { let label = label.into(); + tracing::Span::current().record("label", tracing::field::display(&label)); + let label_hash = LabelHash::new(&label); if matches!( -- cgit v1.2.3-18-g5258