From bf1fb04f23a1970d638289d0b2deaa3e6deab8c9 Mon Sep 17 00:00:00 2001 From: Andrew Walbran Date: Mon, 15 Mar 2021 16:54:09 +0000 Subject: [PATCH] Log to logcat. Bug: 182159441 Test: Ran on VIM3L Change-Id: I9336cd6fea2f94d5b8924d94544cd84b1925dd26 --- virtmanager/Android.bp | 2 +- virtmanager/src/main.rs | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/virtmanager/Android.bp b/virtmanager/Android.bp index 5ff5db45..9fc4f42d 100644 --- a/virtmanager/Android.bp +++ b/virtmanager/Android.bp @@ -9,7 +9,7 @@ rust_binary { edition: "2018", rustlibs: [ "android.system.virtmanager-rust", - "libenv_logger", + "libandroid_logger", "liblog_rust", "libserde_json", "libserde", diff --git a/virtmanager/src/main.rs b/virtmanager/src/main.rs index 7cca4a9e..3ea33d91 100644 --- a/virtmanager/src/main.rs +++ b/virtmanager/src/main.rs @@ -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();