-
Notifications
You must be signed in to change notification settings - Fork 155
Replace log crate with tracing in host code #1044
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: dblnz <[email protected]>
Co-authored-by: dblnz <[email protected]>
| spin = "0.10.0" | ||
|
|
||
| [features] | ||
| default = ["tracing"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if we want to remove the #[instrument] condition from hyperlight-common. But, considering the hyperlight guests can now use the same tracing crate as the host, I think this would be fine
|
|
||
| impl FunctionCall { | ||
| #[cfg_attr(feature = "tracing", instrument(skip_all, parent = Span::current(), level= "Trace"))] | ||
| #[instrument(skip_all, parent = Span::current(), level= "Trace")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can remove parent = Span::current() because it is the default and it is redundant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed parent = Span::current() from all 49 occurrences in flatbuffer_wrappers files and removed the now-unused Span imports. (f4dd6d2)
|
@copilot look at the suggestions |
Co-authored-by: jsturtevant <[email protected]>
dblnz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hyperlight_guest_bin/src/guest_logger.rs needs to also use the tracing crate and not log crate.
Update the other crates to use tracing instead of log where it's the case
src/hyperlight_common/Cargo.toml
Outdated
| anyhow = { version = "1.0.100", default-features = false } | ||
| log = "0.4.28" | ||
| tracing = { version = "0.1.41", optional = true } | ||
| tracing = { version = "0.1.41" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| tracing = { version = "0.1.41" } | |
| tracing = { version = "0.1.41", default-features = false, features = [ "attributes" ] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applied the suggestion and also added the log feature to maintain compatibility: tracing = { version = "0.1.41", default-features = false, features = [ "attributes", "log" ] } (d020eab)
|
@copilot take that suggestions and comments into consideration |
Co-authored-by: dblnz <[email protected]>
Updated all guest code to use
The |
|
@copilot Drop all the changes for the guest crates except for the on in |
Co-authored-by: dblnz <[email protected]>
Reverted all guest crate changes except |
Plan: Replace
logcrate withtracing- ✅ COMPLETElogcratelogimports withtracingequivalents in host source files:parent = Span::current()from instrument attributes (it's the default)Summary of Changes
Host code - completely replaced log with tracing:
logcrate dependency is removed from host crates (hyperlight_host,hyperlight_common,hyperlight_component_util)log::error!→tracing::error!log::warn!→tracing::warn!log::info!→tracing::info!log::debug!→tracing::debug!log::trace!→tracing::trace!log::Level→tracing::Levelwith correct constants (TRACE, DEBUG, INFO, WARN, ERROR)parent = Span::current()from all instrument attributesGuest code - minimal changes:
hyperlight_guest_bin/src/guest_logger.rsinternally usestracing::logtypes for the logger implementationtracing::log::LeveltoLogLevelinhyperlight_commonto support the guest loggerhyperlight_guest_capi, test guests) retain their originallogdependenciesCargo.toml updates:
hyperlight_common: Usestracingwithattributesandlogfeatures (removedlogdependency)hyperlight_host: Removedlogdependency, usestracinghyperlight_component_util: Replacedlogwithtracinghyperlight_guest_bin: Keepslogdependency for guest codehyperlight_guest_capi: Keepslogdependency (unchanged)logdependencies (unchanged)The changes maintain full backward compatibility. Host code uses pure
tracing, while guest code continues to uselogwith minimal internal use oftracing::logfor compatibility in the logger implementation. Embedders can use eitherlogortracingas consumers, and the logging will work correctly in both cases.Original prompt
tracingcrate instead oflogto create logs #1028✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.