Skip to content

Commit 5d31424

Browse files
Copilotdblnz
andcommitted
Replace log crate with tracing in host and component_util
Co-authored-by: dblnz <[email protected]>
1 parent e1aca22 commit 5d31424

File tree

24 files changed

+170
-165
lines changed

24 files changed

+170
-165
lines changed

Cargo.lock

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/hyperlight_common/Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@ workspace = true
1717
[dependencies]
1818
flatbuffers = { version = "25.9.23", default-features = false }
1919
anyhow = { version = "1.0.100", default-features = false }
20-
log = "0.4.28"
21-
tracing = { version = "0.1.41", optional = true }
20+
tracing = { version = "0.1.41" }
2221
arbitrary = {version = "1.4.2", optional = true, features = ["derive"]}
2322
spin = "0.10.0"
2423

2524
[features]
26-
default = ["tracing"]
25+
default = []
2726
fuzzing = ["dep:arbitrary"]
2827
trace_guest = []
2928
mem_profile = []

src/hyperlight_common/src/flatbuffer_wrappers/function_call.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use alloc::vec::Vec;
1919

2020
use anyhow::{Error, Result, bail};
2121
use flatbuffers::{FlatBufferBuilder, WIPOffset, size_prefixed_root};
22-
#[cfg(feature = "tracing")]
2322
use tracing::{Span, instrument};
2423

2524
use super::function_types::{ParameterValue, ReturnType};
@@ -53,7 +52,7 @@ pub struct FunctionCall {
5352
}
5453

5554
impl FunctionCall {
56-
#[cfg_attr(feature = "tracing", instrument(skip_all, parent = Span::current(), level= "Trace"))]
55+
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
5756
pub fn new(
5857
function_name: String,
5958
parameters: Option<Vec<ParameterValue>>,
@@ -214,7 +213,7 @@ impl FunctionCall {
214213
}
215214
}
216215

217-
#[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))]
216+
#[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")]
218217
pub fn validate_guest_function_call_buffer(function_call_buffer: &[u8]) -> Result<()> {
219218
let guest_function_call_fb = size_prefixed_root::<FbFunctionCall>(function_call_buffer)
220219
.map_err(|e| anyhow::anyhow!("Error reading function call buffer: {:?}", e))?;
@@ -226,7 +225,7 @@ pub fn validate_guest_function_call_buffer(function_call_buffer: &[u8]) -> Resul
226225
}
227226
}
228227

229-
#[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))]
228+
#[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")]
230229
pub fn validate_host_function_call_buffer(function_call_buffer: &[u8]) -> Result<()> {
231230
let host_function_call_fb = size_prefixed_root::<FbFunctionCall>(function_call_buffer)
232231
.map_err(|e| anyhow::anyhow!("Error reading function call buffer: {:?}", e))?;
@@ -240,7 +239,7 @@ pub fn validate_host_function_call_buffer(function_call_buffer: &[u8]) -> Result
240239

241240
impl TryFrom<&[u8]> for FunctionCall {
242241
type Error = Error;
243-
#[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))]
242+
#[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")]
244243
fn try_from(value: &[u8]) -> Result<Self> {
245244
let function_call_fb = size_prefixed_root::<FbFunctionCall>(value)
246245
.map_err(|e| anyhow::anyhow!("Error reading function call buffer: {:?}", e))?;

src/hyperlight_common/src/flatbuffer_wrappers/function_types.rs

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use alloc::vec::Vec;
1919

2020
use anyhow::{Error, Result, anyhow, bail};
2121
use flatbuffers::size_prefixed_root;
22-
#[cfg(feature = "tracing")]
2322
use tracing::{Span, instrument};
2423

2524
use super::guest_error::GuestError;
@@ -284,7 +283,7 @@ pub enum ReturnType {
284283
}
285284

286285
impl From<&ParameterValue> for ParameterType {
287-
#[cfg_attr(feature = "tracing", instrument(skip_all, parent = Span::current(), level= "Trace"))]
286+
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
288287
fn from(value: &ParameterValue) -> Self {
289288
match *value {
290289
ParameterValue::Int(_) => ParameterType::Int,
@@ -303,7 +302,7 @@ impl From<&ParameterValue> for ParameterType {
303302
impl TryFrom<Parameter<'_>> for ParameterValue {
304303
type Error = Error;
305304

306-
#[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))]
305+
#[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")]
307306
fn try_from(param: Parameter<'_>) -> Result<Self> {
308307
let value = param.value_type();
309308
let result = match value {
@@ -343,7 +342,7 @@ impl TryFrom<Parameter<'_>> for ParameterValue {
343342
}
344343

345344
impl From<ParameterType> for FbParameterType {
346-
#[cfg_attr(feature = "tracing", instrument(skip_all, parent = Span::current(), level= "Trace"))]
345+
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
347346
fn from(value: ParameterType) -> Self {
348347
match value {
349348
ParameterType::Int => FbParameterType::hlint,
@@ -360,7 +359,7 @@ impl From<ParameterType> for FbParameterType {
360359
}
361360

362361
impl From<ReturnType> for FbReturnType {
363-
#[cfg_attr(feature = "tracing", instrument(skip_all, parent = Span::current(), level= "Trace"))]
362+
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
364363
fn from(value: ReturnType) -> Self {
365364
match value {
366365
ReturnType::Int => FbReturnType::hlint,
@@ -379,7 +378,7 @@ impl From<ReturnType> for FbReturnType {
379378

380379
impl TryFrom<FbParameterType> for ParameterType {
381380
type Error = Error;
382-
#[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))]
381+
#[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")]
383382
fn try_from(value: FbParameterType) -> Result<Self> {
384383
match value {
385384
FbParameterType::hlint => Ok(ParameterType::Int),
@@ -400,7 +399,7 @@ impl TryFrom<FbParameterType> for ParameterType {
400399

401400
impl TryFrom<FbReturnType> for ReturnType {
402401
type Error = Error;
403-
#[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))]
402+
#[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")]
404403
fn try_from(value: FbReturnType) -> Result<Self> {
405404
match value {
406405
FbReturnType::hlint => Ok(ReturnType::Int),
@@ -422,7 +421,7 @@ impl TryFrom<FbReturnType> for ReturnType {
422421

423422
impl TryFrom<ParameterValue> for i32 {
424423
type Error = Error;
425-
#[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))]
424+
#[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")]
426425
fn try_from(value: ParameterValue) -> Result<Self> {
427426
match value {
428427
ParameterValue::Int(v) => Ok(v),
@@ -435,7 +434,7 @@ impl TryFrom<ParameterValue> for i32 {
435434

436435
impl TryFrom<ParameterValue> for u32 {
437436
type Error = Error;
438-
#[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))]
437+
#[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")]
439438
fn try_from(value: ParameterValue) -> Result<Self> {
440439
match value {
441440
ParameterValue::UInt(v) => Ok(v),
@@ -448,7 +447,7 @@ impl TryFrom<ParameterValue> for u32 {
448447

449448
impl TryFrom<ParameterValue> for i64 {
450449
type Error = Error;
451-
#[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))]
450+
#[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")]
452451
fn try_from(value: ParameterValue) -> Result<Self> {
453452
match value {
454453
ParameterValue::Long(v) => Ok(v),
@@ -461,7 +460,7 @@ impl TryFrom<ParameterValue> for i64 {
461460

462461
impl TryFrom<ParameterValue> for u64 {
463462
type Error = Error;
464-
#[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))]
463+
#[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")]
465464
fn try_from(value: ParameterValue) -> Result<Self> {
466465
match value {
467466
ParameterValue::ULong(v) => Ok(v),
@@ -474,7 +473,7 @@ impl TryFrom<ParameterValue> for u64 {
474473

475474
impl TryFrom<ParameterValue> for f32 {
476475
type Error = Error;
477-
#[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))]
476+
#[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")]
478477
fn try_from(value: ParameterValue) -> Result<Self> {
479478
match value {
480479
ParameterValue::Float(v) => Ok(v),
@@ -487,7 +486,7 @@ impl TryFrom<ParameterValue> for f32 {
487486

488487
impl TryFrom<ParameterValue> for f64 {
489488
type Error = Error;
490-
#[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))]
489+
#[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")]
491490
fn try_from(value: ParameterValue) -> Result<Self> {
492491
match value {
493492
ParameterValue::Double(v) => Ok(v),
@@ -500,7 +499,7 @@ impl TryFrom<ParameterValue> for f64 {
500499

501500
impl TryFrom<ParameterValue> for String {
502501
type Error = Error;
503-
#[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))]
502+
#[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")]
504503
fn try_from(value: ParameterValue) -> Result<Self> {
505504
match value {
506505
ParameterValue::String(v) => Ok(v),
@@ -513,7 +512,7 @@ impl TryFrom<ParameterValue> for String {
513512

514513
impl TryFrom<ParameterValue> for bool {
515514
type Error = Error;
516-
#[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))]
515+
#[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")]
517516
fn try_from(value: ParameterValue) -> Result<Self> {
518517
match value {
519518
ParameterValue::Bool(v) => Ok(v),
@@ -526,7 +525,7 @@ impl TryFrom<ParameterValue> for bool {
526525

527526
impl TryFrom<ParameterValue> for Vec<u8> {
528527
type Error = Error;
529-
#[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))]
528+
#[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")]
530529
fn try_from(value: ParameterValue) -> Result<Self> {
531530
match value {
532531
ParameterValue::VecBytes(v) => Ok(v),
@@ -539,7 +538,7 @@ impl TryFrom<ParameterValue> for Vec<u8> {
539538

540539
impl TryFrom<ReturnValue> for i32 {
541540
type Error = Error;
542-
#[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))]
541+
#[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")]
543542
fn try_from(value: ReturnValue) -> Result<Self> {
544543
match value {
545544
ReturnValue::Int(v) => Ok(v),
@@ -552,7 +551,7 @@ impl TryFrom<ReturnValue> for i32 {
552551

553552
impl TryFrom<ReturnValue> for u32 {
554553
type Error = Error;
555-
#[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))]
554+
#[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")]
556555
fn try_from(value: ReturnValue) -> Result<Self> {
557556
match value {
558557
ReturnValue::UInt(v) => Ok(v),
@@ -565,7 +564,7 @@ impl TryFrom<ReturnValue> for u32 {
565564

566565
impl TryFrom<ReturnValue> for i64 {
567566
type Error = Error;
568-
#[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))]
567+
#[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")]
569568
fn try_from(value: ReturnValue) -> Result<Self> {
570569
match value {
571570
ReturnValue::Long(v) => Ok(v),
@@ -578,7 +577,7 @@ impl TryFrom<ReturnValue> for i64 {
578577

579578
impl TryFrom<ReturnValue> for u64 {
580579
type Error = Error;
581-
#[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))]
580+
#[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")]
582581
fn try_from(value: ReturnValue) -> Result<Self> {
583582
match value {
584583
ReturnValue::ULong(v) => Ok(v),
@@ -591,7 +590,7 @@ impl TryFrom<ReturnValue> for u64 {
591590

592591
impl TryFrom<ReturnValue> for f32 {
593592
type Error = Error;
594-
#[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))]
593+
#[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")]
595594
fn try_from(value: ReturnValue) -> Result<Self> {
596595
match value {
597596
ReturnValue::Float(v) => Ok(v),
@@ -604,7 +603,7 @@ impl TryFrom<ReturnValue> for f32 {
604603

605604
impl TryFrom<ReturnValue> for f64 {
606605
type Error = Error;
607-
#[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))]
606+
#[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")]
608607
fn try_from(value: ReturnValue) -> Result<Self> {
609608
match value {
610609
ReturnValue::Double(v) => Ok(v),
@@ -617,7 +616,7 @@ impl TryFrom<ReturnValue> for f64 {
617616

618617
impl TryFrom<ReturnValue> for String {
619618
type Error = Error;
620-
#[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))]
619+
#[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")]
621620
fn try_from(value: ReturnValue) -> Result<Self> {
622621
match value {
623622
ReturnValue::String(v) => Ok(v),
@@ -630,7 +629,7 @@ impl TryFrom<ReturnValue> for String {
630629

631630
impl TryFrom<ReturnValue> for bool {
632631
type Error = Error;
633-
#[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))]
632+
#[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")]
634633
fn try_from(value: ReturnValue) -> Result<Self> {
635634
match value {
636635
ReturnValue::Bool(v) => Ok(v),
@@ -643,7 +642,7 @@ impl TryFrom<ReturnValue> for bool {
643642

644643
impl TryFrom<ReturnValue> for Vec<u8> {
645644
type Error = Error;
646-
#[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))]
645+
#[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")]
647646
fn try_from(value: ReturnValue) -> Result<Self> {
648647
match value {
649648
ReturnValue::VecBytes(v) => Ok(v),
@@ -656,7 +655,7 @@ impl TryFrom<ReturnValue> for Vec<u8> {
656655

657656
impl TryFrom<ReturnValue> for () {
658657
type Error = Error;
659-
#[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))]
658+
#[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")]
660659
fn try_from(value: ReturnValue) -> Result<Self> {
661660
match value {
662661
ReturnValue::Void(()) => Ok(()),
@@ -669,7 +668,7 @@ impl TryFrom<ReturnValue> for () {
669668

670669
impl TryFrom<ReturnValueBox<'_>> for ReturnValue {
671670
type Error = Error;
672-
#[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))]
671+
#[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")]
673672
fn try_from(return_value_box: ReturnValueBox<'_>) -> Result<Self> {
674673
match return_value_box.value_type() {
675674
FbReturnValue::hlint => {
@@ -740,7 +739,7 @@ impl TryFrom<ReturnValueBox<'_>> for ReturnValue {
740739

741740
impl TryFrom<&ReturnValue> for Vec<u8> {
742741
type Error = Error;
743-
#[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))]
742+
#[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")]
744743
fn try_from(value: &ReturnValue) -> Result<Vec<u8>> {
745744
let mut builder = flatbuffers::FlatBufferBuilder::new();
746745
let result_bytes = match value {

src/hyperlight_common/src/flatbuffer_wrappers/guest_error.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ extern crate flatbuffers;
1818

1919
use alloc::string::{String, ToString};
2020

21-
#[cfg(feature = "tracing")]
2221
use tracing::{Span, instrument};
2322

2423
use crate::flatbuffers::hyperlight::generated::ErrorCode as FbErrorCode;
@@ -189,14 +188,14 @@ pub struct GuestError {
189188
}
190189

191190
impl GuestError {
192-
#[cfg_attr(feature = "tracing", instrument(skip_all, parent = Span::current(), level= "Trace"))]
191+
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
193192
pub fn new(code: ErrorCode, message: String) -> Self {
194193
Self { code, message }
195194
}
196195
}
197196

198197
impl Default for GuestError {
199-
#[cfg_attr(feature = "tracing", instrument(parent = Span::current(), level= "Trace"))]
198+
#[instrument(parent = Span::current(), level= "Trace")]
200199
fn default() -> Self {
201200
Self {
202201
code: ErrorCode::NoError,

0 commit comments

Comments
 (0)