diff options
| author | HampusM <hampus@hampusmat.com> | 2026-09-27 20:48:35 +0200 |
|---|---|---|
| committer | HampusM <hampus@hampusmat.com> | 2026-09-27 20:48:35 +0200 |
| commit | 052b252173507fca07b622ddec33fa2417692ae3 (patch) | |
| tree | 8a6268c30bb7f072d6e7298f09f3e285ab2b6626 | |
| parent | ee6e010611433f0aad53e3c99571b8a8c6ca13f4 (diff) | |
feat(engine): improve & add fields to logs in Assets fns
| -rw-r--r-- | engine/src/asset.rs | 22 |
1 files changed, 15 insertions, 7 deletions
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::<AssetT>()) + fields(asset_label, asset_type = %type_name::<AssetT>()) )] pub fn get<AssetT>(&self, handle: &Handle<AssetT>) -> Option<&AssetT> where @@ -201,7 +201,7 @@ impl Assets Some(asset) } - #[tracing::instrument(skip_all, fields(asset_type=type_name::<AssetT>()))] + #[tracing::instrument(skip_all, fields(label, asset_type = %type_name::<AssetT>()))] pub fn get_handle_to_loaded<'label, AssetT>( &self, label: impl Into<Label<'label>>, @@ -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<Label<'i>> + Debug) -> Handle<AssetT> + #[tracing::instrument(skip_all, fields(label, asset_type = %type_name::<AssetT>()))] + pub fn load<'i, AssetT>(&self, label: impl Into<Label<'i>>) -> Handle<AssetT> 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::<AssetT>()))] pub fn load_with_settings<'i, AssetT, AssetSettings>( &self, label: impl Into<Label<'i>> + 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::<AssetT>()))] + #[tracing::instrument(skip_all, fields(label, asset_type = %type_name::<AssetT>()))] pub fn store_with_label<'i, AssetT>( &mut self, - label: impl Into<Label<'i>> + Debug, + label: impl Into<Label<'i>>, asset: AssetT, ) -> Handle<AssetT> 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!( |
