Skip to content

Commit 2f8187e

Browse files
Copilotjsturtevant
andcommitted
Add log dependency back for guest environments and fix conversions
Co-authored-by: jsturtevant <[email protected]>
1 parent a43a330 commit 2f8187e

File tree

5 files changed

+21
-1
lines changed

5 files changed

+21
-1
lines changed

Cargo.lock

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

src/hyperlight_common/src/flatbuffer_wrappers/guest_log_level.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ use anyhow::{Error, Result, bail};
1818
#[cfg(feature = "tracing")]
1919
use tracing::{Span, instrument};
2020

21+
#[cfg(feature = "std")]
22+
extern crate log;
23+
2124
use crate::flatbuffers::hyperlight::generated::LogLevel as FbLogLevel;
2225

2326
// Define a minimal Level enum for conversions.
@@ -122,3 +125,18 @@ impl From<Level> for LogLevel {
122125
}
123126
}
124127
}
128+
129+
// Conversion from log::Level (which guest logger uses) to LogLevel
130+
// Only available when std feature is enabled (for guest environments)
131+
#[cfg(feature = "std")]
132+
impl From<log::Level> for LogLevel {
133+
fn from(val: log::Level) -> LogLevel {
134+
match val {
135+
log::Level::Trace => LogLevel::Trace,
136+
log::Level::Debug => LogLevel::Debug,
137+
log::Level::Info => LogLevel::Information,
138+
log::Level::Warn => LogLevel::Warning,
139+
log::Level::Error => LogLevel::Error,
140+
}
141+
}
142+
}

src/hyperlight_guest_bin/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ hyperlight-common = { workspace = true, default-features = false }
2727
hyperlight-guest-tracing = { workspace = true, default-features = false }
2828
hyperlight-guest-macro = { workspace = true, default-features = false, optional = true }
2929
buddy_system_allocator = "0.11.0"
30+
log = { version = "0.4", default-features = false }
3031
linkme = { version = "0.3.35", optional = true }
3132
spin = "0.10.0"
3233
flatbuffers = { version = "25.2.10", default-features = false }

src/tests/rust_guests/simpleguest/Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/tests/rust_guests/simpleguest/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ hyperlight-guest = { path = "../../../hyperlight_guest" }
88
hyperlight-guest-bin = { path = "../../../hyperlight_guest_bin" }
99
hyperlight-common = { path = "../../../hyperlight_common", default-features = false }
1010
hyperlight-guest-tracing = { path = "../../../hyperlight_guest_tracing" }
11+
log = {version = "0.4", default-features = false }
1112
tracing = { version = "0.1.41", default-features = false, features = ["log", "attributes"] }
1213

1314
[features]

0 commit comments

Comments
 (0)