From c7b0c7b2ea4181150fc99d7c9fab3112f9037187 Mon Sep 17 00:00:00 2001 From: Shailesh Vashishth Date: Sat, 14 Feb 2026 01:23:18 +0530 Subject: [PATCH] Changes hl component util to use tracing crate Signed-off-by: Shailesh Vashishth --- Cargo.lock | 2 +- src/hyperlight_component_util/Cargo.toml | 2 +- src/hyperlight_component_util/src/emit.rs | 10 +++++----- src/hyperlight_component_util/src/guest.rs | 2 +- src/hyperlight_component_util/src/hl.rs | 8 ++++---- src/hyperlight_component_util/src/host.rs | 4 ++-- src/hyperlight_component_util/src/rtypes.rs | 14 +++++++------- src/hyperlight_component_util/src/util.rs | 2 +- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 08e1d7468..5bde48c71 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1437,11 +1437,11 @@ name = "hyperlight-component-util" version = "0.12.0" dependencies = [ "itertools 0.14.0", - "log", "prettyplease", "proc-macro2", "quote", "syn", + "tracing", "wasmparser", ] diff --git a/src/hyperlight_component_util/Cargo.toml b/src/hyperlight_component_util/Cargo.toml index b45408266..a0c6fb175 100644 --- a/src/hyperlight_component_util/Cargo.toml +++ b/src/hyperlight_component_util/Cargo.toml @@ -21,4 +21,4 @@ proc-macro2 = { version = "1.0.106" } syn = { version = "2.0.114" } itertools = { version = "0.14.0" } prettyplease = { version = "0.2.37" } -log = { version = "0.4" } \ No newline at end of file +tracing = { version = "0.1.44", features = ["log"]} \ No newline at end of file diff --git a/src/hyperlight_component_util/src/emit.rs b/src/hyperlight_component_util/src/emit.rs index 1b3545813..d6c67cdf7 100644 --- a/src/hyperlight_component_util/src/emit.rs +++ b/src/hyperlight_component_util/src/emit.rs @@ -416,7 +416,7 @@ impl<'a, 'b> State<'a, 'b> { let Some(ref mut cnvs) = self.cur_needs_vars else { return; }; - log::debug!("debug varref: recording {:?} for var {:?}", cnvs.iter(), un); + tracing::debug!("debug varref: recording {:?} for var {:?}", cnvs.iter(), un); self.vars_needs_vars[un].extend(cnvs.iter()); } /// Get a list of all the variables needed by a var, given its absolute @@ -426,7 +426,7 @@ impl<'a, 'b> State<'a, 'b> { if self.vars_needs_vars.len() < un + 1 { return BTreeSet::new(); }; - log::debug!( + tracing::debug!( "debug varref: looking up {:?} for var {:?}", self.vars_needs_vars[un].iter(), un @@ -559,7 +559,7 @@ impl<'a, 'b> State<'a, 'b> { Defined::Handleable(Handleable::Var(tv)) => match tv { Tyvar::Bound(n) => { let bv = &self.bound_vars[self.var_offset + (*n as usize)]; - log::debug!("checking an origin {:?} {:?}", bv.origin, self.origin); + tracing::debug!("checking an origin {:?} {:?}", bv.origin, self.origin); if bv.origin.matches(self.origin.iter()) { Some((*n, bv.bound.clone())) } else { @@ -588,7 +588,7 @@ impl<'a, 'b> State<'a, 'b> { /// /// Precondition: all named traits/modules must exist pub fn resolve_trait_immut(&self, absolute: bool, path: &[Ident]) -> &Trait { - log::debug!("resolving trait {:?} {:?}", absolute, path); + tracing::debug!("resolving trait {:?} {:?}", absolute, path); let mut m = if absolute { &*self.root_mod } else { @@ -611,7 +611,7 @@ impl<'a, 'b> State<'a, 'b> { .enumerate() .for_each(|(i, vs)| { *vs = vs.iter().map(|v| v + n).collect(); - log::debug!("updated {:?} to {:?}", i, *vs); + tracing::debug!("updated {:?} to {:?}", i, *vs); }); for _ in 0..n { self.vars_needs_vars.push_front(BTreeSet::new()); diff --git a/src/hyperlight_component_util/src/guest.rs b/src/hyperlight_component_util/src/guest.rs index 09e909034..27469cbec 100644 --- a/src/hyperlight_component_util/src/guest.rs +++ b/src/hyperlight_component_util/src/guest.rs @@ -344,7 +344,7 @@ fn emit_component<'a, 'b, 'c>( /// - functions when given a type that implements the `Guest` trait pub fn emit_toplevel<'a, 'b, 'c>(s: &'c mut State<'a, 'b>, n: &str, ct: &'c Component<'b>) { s.is_impl = true; - log::debug!("\n\n=== starting guest emit ===\n"); + tracing::debug!("\n\n=== starting guest emit ===\n"); let wn = split_wit_name(n); let ns = wn.namespace_path(); diff --git a/src/hyperlight_component_util/src/hl.rs b/src/hyperlight_component_util/src/hl.rs index d58eb7aaf..5b7211cf3 100644 --- a/src/hyperlight_component_util/src/hl.rs +++ b/src/hyperlight_component_util/src/hl.rs @@ -298,7 +298,7 @@ pub fn emit_hl_unmarshal_value(s: &mut State, id: Ident, vt: &Value) -> TokenStr } Value::Own(ht) => { let vi = resolve_handleable_to_resource(s, ht); - log::debug!("resolved ht to r (1) {:?} {:?}", ht, vi); + tracing::debug!("resolved ht to r (1) {:?} {:?}", ht, vi); if s.is_guest { let rid = format_ident!("HostResource{}", vi); if s.is_wasmtime_guest { @@ -326,7 +326,7 @@ pub fn emit_hl_unmarshal_value(s: &mut State, id: Ident, vt: &Value) -> TokenStr } Value::Borrow(ht) => { let vi = resolve_handleable_to_resource(s, ht); - log::debug!("resolved ht to r (2) {:?} {:?}", ht, vi); + tracing::debug!("resolved ht to r (2) {:?} {:?}", ht, vi); if s.is_guest { let rid = format_ident!("HostResource{}", vi); if s.is_wasmtime_guest { @@ -624,7 +624,7 @@ pub fn emit_hl_marshal_value(s: &mut State, id: Ident, vt: &Value) -> TokenStrea } Value::Own(ht) => { let vi = resolve_handleable_to_resource(s, ht); - log::debug!("resolved ht to r (3) {:?} {:?}", ht, vi); + tracing::debug!("resolved ht to r (3) {:?} {:?}", ht, vi); if s.is_guest { let call = if s.is_wasmtime_guest { quote! { () } @@ -645,7 +645,7 @@ pub fn emit_hl_marshal_value(s: &mut State, id: Ident, vt: &Value) -> TokenStrea } Value::Borrow(ht) => { let vi = resolve_handleable_to_resource(s, ht); - log::debug!("resolved ht to r (6) {:?} {:?}", ht, vi); + tracing::debug!("resolved ht to r (6) {:?} {:?}", ht, vi); if s.is_guest { let call = if s.is_wasmtime_guest { quote! { () } diff --git a/src/hyperlight_component_util/src/host.rs b/src/hyperlight_component_util/src/host.rs index 0f6bca65b..79b682332 100644 --- a/src/hyperlight_component_util/src/host.rs +++ b/src/hyperlight_component_util/src/host.rs @@ -202,7 +202,7 @@ fn emit_import_extern_decl<'a, 'b, 'c>( ExternDesc::CoreModule(_) => panic!("core module (im/ex)ports are not supported"), ExternDesc::Func(ft) => { let hln = emit_fn_hl_name(s, ed.kebab_name); - log::debug!("providing host function {}", hln); + tracing::debug!("providing host function {}", hln); let (pds, pus) = ft .params .iter() @@ -382,7 +382,7 @@ fn emit_component<'a, 'b, 'c>(s: &'c mut State<'a, 'b>, wn: WitName, ct: &'c Com /// See [`emit_component`] pub fn emit_toplevel<'a, 'b, 'c>(s: &'c mut State<'a, 'b>, n: &str, ct: &'c Component<'b>) { s.is_impl = true; - log::debug!("\n\n=== starting host emit ===\n"); + tracing::debug!("\n\n=== starting host emit ===\n"); let wn = split_wit_name(n); emit_component(s, wn, ct) } diff --git a/src/hyperlight_component_util/src/rtypes.rs b/src/hyperlight_component_util/src/rtypes.rs index 18665db31..427344dae 100644 --- a/src/hyperlight_component_util/src/rtypes.rs +++ b/src/hyperlight_component_util/src/rtypes.rs @@ -164,7 +164,7 @@ fn try_find_local_var_id( return Some(emit_resource_ref(s, n, path)); } } - log::debug!("path is {:?}\n", path); + tracing::debug!("path is {:?}\n", path); let mut path = path.iter().rev(); let name = kebab_to_type(path.next().unwrap().name()); let owner = path.next(); @@ -216,7 +216,7 @@ pub fn emit_var_ref_value(s: &mut State, tv: &Tyvar) -> TokenStream { /// the bound variable being referenced /// - `is_value`: whether this is a value (e.g. constructor) or type context. pub fn emit_var_ref_noff(s: &mut State, n: u32, is_value: bool) -> TokenStream { - log::debug!("var_ref {:?} {:?}", &s.bound_vars[n as usize], s.origin); + tracing::debug!("var_ref {:?} {:?}", &s.bound_vars[n as usize], s.origin); // if the variable was defined locally, try to reference it directly let id = try_find_local_var_id(s, n); let id = match id { @@ -317,7 +317,7 @@ pub fn emit_value(s: &mut State, vt: &Value) -> TokenStream { wrap(emit_var_ref(s, tv)) } else { let n = crate::hl::resolve_handleable_to_resource(s, ht); - log::debug!("resolved ht to r (4) {:?} {:?}", ht, n); + tracing::debug!("resolved ht to r (4) {:?} {:?}", ht, n); let id = format_ident!("HostResource{}", n); wrap(quote! { #id }) } @@ -339,7 +339,7 @@ pub fn emit_value(s: &mut State, vt: &Value) -> TokenStream { wrap(emit_var_ref(s, tv)) } else { let n = crate::hl::resolve_handleable_to_resource(s, ht); - log::debug!("resolved ht to r (5) {:?} {:?}", ht, n); + tracing::debug!("resolved ht to r (5) {:?} {:?}", ht, n); let id = format_ident!("HostResource{}", n); wrap(quote! { #id }) } @@ -619,7 +619,7 @@ fn emit_extern_decl<'a, 'b, 'c>( s: &'c mut State<'a, 'b>, ed: &'c ExternDecl<'b>, ) -> TokenStream { - log::debug!(" emitting decl {:?}", ed.kebab_name); + tracing::debug!(" emitting decl {:?}", ed.kebab_name); match &ed.desc { ExternDesc::CoreModule(_) => panic!("core module (im/ex)ports are not supported"), ExternDesc::Func(ft) => { @@ -749,7 +749,7 @@ fn emit_extern_decl<'a, 'b, 'c>( /// Emit (via mutating `s`) a Rust trait declaration corresponding to /// this instance type fn emit_instance<'a, 'b, 'c>(s: &'c mut State<'a, 'b>, wn: WitName, it: &'c Instance<'b>) { - log::debug!("emitting instance {:?}", wn); + tracing::debug!("emitting instance {:?}", wn); let mut s = s.with_cursor(wn.namespace_idents()); let name = kebab_to_type(wn.name); @@ -801,7 +801,7 @@ fn emit_instance<'a, 'b, 'c>(s: &'c mut State<'a, 'b>, wn: WitName, it: &'c Inst } drop(sv); - log::debug!("after exports, ncur_needs_vars is {:?}", needs_vars); + tracing::debug!("after exports, ncur_needs_vars is {:?}", needs_vars); for v in needs_vars { let id = s.noff_var_id(v); s.cur_trait().tvs.insert(id, (Some(v), TokenStream::new())); diff --git a/src/hyperlight_component_util/src/util.rs b/src/hyperlight_component_util/src/util.rs index c068721d8..8e1960a30 100644 --- a/src/hyperlight_component_util/src/util.rs +++ b/src/hyperlight_component_util/src/util.rs @@ -47,7 +47,7 @@ pub fn read_wit_type_from_file R>( let ExternDesc::Component(ct) = &export.desc else { panic!("malformed component type container: does not contain component type"); }; - log::debug!("hcm: considering component type {:?}", ct); + tracing::debug!("hcm: considering component type {:?}", ct); cb(export.kebab_name.to_string(), ct) }