diff --git a/CHANGELOG.md b/CHANGELOG.md index c66c31cdb..f50c99d09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,10 @@ `error!`. This removes an extraneous file name and line number from the log message. +- Added a `logger` feature which reflects the same feature in `uefi`. + This allows using both crates while disabling `logger` in `uefi`, + which was previously impossible. + ## uefi - 0.17.0 ### Added diff --git a/uefi-services/Cargo.toml b/uefi-services/Cargo.toml index 1355e8982..458fb8f43 100644 --- a/uefi-services/Cargo.toml +++ b/uefi-services/Cargo.toml @@ -15,13 +15,14 @@ is-it-maintained-issue-resolution = { repository = "rust-osdev/uefi-rs" } is-it-maintained-open-issues = { repository = "rust-osdev/uefi-rs" } [dependencies] -uefi = { version = "0.17.0", features = ["alloc", "logger"] } +uefi = { version = "0.17.0", features = ["alloc"] } log = { version = "0.4.5", default-features = false } cfg-if = "1.0.0" qemu-exit = { version = "3.0.1", optional = true } [features] -default = ["panic_handler"] +default = ["panic_handler", "logger"] # Enable QEMU-specific functionality qemu = ["qemu-exit"] panic_handler = [] +logger = ["uefi/logger"] diff --git a/uefi-services/src/lib.rs b/uefi-services/src/lib.rs index efbe3dfe5..40a1e35a4 100644 --- a/uefi-services/src/lib.rs +++ b/uefi-services/src/lib.rs @@ -43,6 +43,7 @@ use uefi::{Event, Result}; static mut SYSTEM_TABLE: Option> = None; /// Global logger object +#[cfg(feature = "logger")] static mut LOGGER: Option = None; /// Obtains a pointer to the system table. @@ -77,7 +78,10 @@ pub fn init(st: &mut SystemTable) -> Result { SYSTEM_TABLE = Some(st.unsafe_clone()); // Setup logging and memory allocation + + #[cfg(feature = "logger")] init_logger(st); + let boot_services = st.boot_services(); uefi::alloc::init(boot_services); @@ -144,6 +148,7 @@ macro_rules! println { /// /// This is unsafe because you must arrange for the logger to be reset with /// disable() on exit from UEFI boot services. +#[cfg(feature = "logger")] unsafe fn init_logger(st: &mut SystemTable) { let stdout = st.stdout(); @@ -170,6 +175,8 @@ unsafe extern "efiapi" fn exit_boot_services(_e: Event, _ctx: Option