Merge "Log to logcat."

This commit is contained in:
Andrew Walbran 2021-03-16 11:09:27 +00:00 committed by Gerrit Code Review
commit 22c92a9699
2 changed files with 8 additions and 3 deletions

View File

@ -9,7 +9,7 @@ rust_binary {
edition: "2018",
rustlibs: [
"android.system.virtmanager-rust",
"libenv_logger",
"libandroid_logger",
"liblog_rust",
"libserde_json",
"libserde",

View File

@ -21,17 +21,22 @@ mod crosvm;
use crate::aidl::{VirtManager, BINDER_SERVICE_IDENTIFIER};
use android_system_virtmanager::aidl::android::system::virtmanager::IVirtManager::BnVirtManager;
use android_system_virtmanager::binder::{add_service, ProcessState};
use log::info;
use log::{info, Level};
/// The first CID to assign to a guest VM managed by the Virt Manager. CIDs lower than this are
/// reserved for the host or other usage.
const FIRST_GUEST_CID: Cid = 10;
const LOG_TAG: &str = "VirtManager";
/// The unique ID of a VM used (together with a port number) for vsock communication.
type Cid = u32;
fn main() {
env_logger::init();
android_logger::init_once(android_logger::Config::default().with_tag(LOG_TAG).with_min_level(
if env!("TARGET_BUILD_VARIANT") == "user" { Level::Info } else { Level::Trace },
));
let virt_manager = VirtManager::default();
let virt_manager = BnVirtManager::new_binder(virt_manager);
add_service(BINDER_SERVICE_IDENTIFIER, virt_manager.as_binder()).unwrap();