vmbase: Initialize logger before calling main()
By setting up the console (MMIO_GUARD_MAP-ing it if necessary) and
initializing the logger before entering main, we can centralize the
early error handling instead of expecting clients to deal with it,
provide a standard interface for configuring the log level (relying on
the log crate) which can't fail, and simplify client code.
This will enable vmbase itself to log errors in future changes.
Test: atest DebugPolicyHostTests#testNoAdbInDebugPolicy_withDebugLevelNone_boots
Test: atest rialto_test vmbase_example.integration_test
Change-Id: Id8c7256555d7940174c9f9375435d71851302020
diff --git a/vmbase/src/logger.rs b/vmbase/src/logger.rs
index 226d905..9130918 100644
--- a/vmbase/src/logger.rs
+++ b/vmbase/src/logger.rs
@@ -20,7 +20,7 @@
use crate::console::println;
use core::sync::atomic::{AtomicBool, Ordering};
-use log::{LevelFilter, Log, Metadata, Record, SetLoggerError};
+use log::{Log, Metadata, Record, SetLoggerError};
struct Logger {
is_enabled: AtomicBool,
@@ -70,9 +70,8 @@
}
/// Initialize vmbase logger with a given max logging level.
-pub fn init(max_level: LevelFilter) -> Result<(), SetLoggerError> {
+pub(crate) fn init() -> Result<(), SetLoggerError> {
log::set_logger(&LOGGER)?;
- log::set_max_level(max_level);
Ok(())
}