refactor: replace tracing-log with native tracing macros for guest log forwarding#1500
Conversation
…g forwarding Remove the tracing-log dependency from hyperlight-host and replace the format_trace/log::Record approach in outb_log with direct tracing event macros (error!, warn!, info!, debug!, trace!). This consolidates guest log emission on the tracing crate, while preserving backward compatibility for consumers using only the log crate (via tracing's built-in log feature). Closes hyperlight-dev#1028 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: cshung <3410332+cshung@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR migrates guest/host logging paths away from log records + tracing-log formatting and toward emitting tracing events directly, while updating tests and dependencies accordingly.
Changes:
- Emit guest log messages in
outb_logas structuredtracing::*events instead of formatting alog::Recordviatracing_log::format_trace. - Replace some
logmacro usage/imports withtracingin guest and integration tests. - Remove the
tracing-logdependency fromhyperlight_host.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/tests/rust_guests/simpleguest/src/main.rs | Adjust imports and switch one traced log site to tracing::info!. |
| src/hyperlight_host/tests/integration_test.rs | Use tracing::{error, trace} instead of log::{error, trace}. |
| src/hyperlight_host/src/sandbox/outb.rs | Rework outb_log to emit tracing events with guest metadata as fields; update tests accordingly. |
| src/hyperlight_host/Cargo.toml | Drop tracing-log dependency. |
There was a problem hiding this comment.
Thanks for contribution! Would you mind also updating docs/hyperlight-metrics-logs-and-traces.md (remove any mention of tracing-log crate for exapmle). Thanks!
Eventually I want to get rid of all logging (non-tracing) code in both guest and host, so if you're up for doing something more relating to this topic we would greatly appreciate it!
Remove references to tracing-log crate and LogTracer from the metrics/logs/traces documentation. Updated to reflect that Hyperlight now uses the tracing crate's built-in log feature for forwarding events to log consumers. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: cshung <3410332+cshung@users.noreply.github.com>
Rename tracing event fields from guest_source_file to guest_file and keep guest_line and guest_module consistent with the shorter naming convention requested in review. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: cshung <3410332+cshung@users.noreply.github.com>
Summary
Remove the
tracing-logdependency from hyperlight-host and replace theformat_trace/log::Recordapproach inoutb_logwith direct tracing event macros (error!,warn!,info!,debug!,trace!).This consolidates guest log emission on the
tracingcrate, while preserving backward compatibility for consumers using only thelogcrate (via tracing's built-inlogfeature).Changes
tracing-logdependencyformat_trace/log::Recordwith nativetracingmacros matched onLogLeveluse log::{error, trace}touse tracing::{error, trace}log::info!totracing::info!(keptlogimport for backward compat test)Testing
test_log_outb_logverifies backward compatibility withlog-only consumerstest_trace_outb_logverifies tracing subscriber pathCloses #1028