Skip to content

refactor: replace tracing-log with native tracing macros for guest log forwarding#1500

Merged
ludfjig merged 3 commits into
hyperlight-dev:mainfrom
cshung:tracing-consolidation
Jun 4, 2026
Merged

refactor: replace tracing-log with native tracing macros for guest log forwarding#1500
ludfjig merged 3 commits into
hyperlight-dev:mainfrom
cshung:tracing-consolidation

Conversation

@cshung
Copy link
Copy Markdown
Contributor

@cshung cshung commented Jun 2, 2026

Summary

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).

Changes

  • src/hyperlight_host/Cargo.toml: Removed tracing-log dependency
  • src/hyperlight_host/src/sandbox/outb.rs: Replaced format_trace/log::Record with native tracing macros matched on LogLevel
  • src/hyperlight_host/tests/integration_test.rs: Switched use log::{error, trace} to use tracing::{error, trace}
  • src/tests/rust_guests/simpleguest/src/main.rs: Switched log::info! to tracing::info! (kept log import for backward compat test)

Testing

  • All unit tests pass (debug + release)
  • All integration tests pass (debug + release)
  • Clippy clean (debug + release)
  • test_log_outb_log verifies backward compatibility with log-only consumers
  • test_trace_outb_log verifies tracing subscriber path

Closes #1028

…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>
Copilot AI review requested due to automatic review settings June 2, 2026 20:49
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_log as structured tracing::* events instead of formatting a log::Record via tracing_log::format_trace.
  • Replace some log macro usage/imports with tracing in guest and integration tests.
  • Remove the tracing-log dependency from hyperlight_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.

Comment thread src/hyperlight_host/src/sandbox/outb.rs
Comment thread src/hyperlight_host/src/sandbox/outb.rs
@ludfjig ludfjig added the kind/refactor For PRs that restructure or remove code without adding new functionality. label Jun 2, 2026
Copy link
Copy Markdown
Contributor

@ludfjig ludfjig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

Comment thread src/hyperlight_host/src/sandbox/outb.rs
cshung and others added 2 commits June 3, 2026 18:45
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>
Copy link
Copy Markdown
Contributor

@ludfjig ludfjig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@ludfjig ludfjig merged commit 1a90b49 into hyperlight-dev:main Jun 4, 2026
40 checks passed
@cshung cshung deleted the tracing-consolidation branch June 4, 2026 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/refactor For PRs that restructure or remove code without adding new functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use tracing crate instead of log to create logs

3 participants