rustlibs: [
"libtokio",
"libnix",
+ "liblog_rust",
],
+ target: {
+ android: {
+ rustlibs: [
+ "libandroid_logger",
+ ],
+ },
+ host: {
+ rustlibs: [
+ "libenv_logger",
+ ],
+ },
+ },
host_supported: true,
}
rustlibs: [
"libtokio",
"libnix",
+ "liblog_rust",
+ "libenv_logger",
],
}
#[cfg(test)]
#[macro_use]
mod asserts;
+
+/// Inits logging for Android
+#[cfg(target_os = "android")]
+pub fn init_logging() {
+ android_logger::init_once(
+ android_logger::Config::default()
+ .with_tag("bt")
+ .with_min_level(log::Level::Debug),
+ );
+}
+
+/// Inits logging for host
+#[cfg(not(target_os = "android"))]
+pub fn init_logging() {
+ env_logger::Builder::new()
+ .filter(None, log::LevelFilter::Debug)
+ .parse_default_env()
+ .init();
+}
"libgrpcio",
"libtokio",
"libnix",
+ "libbt_common",
+ "liblog_rust",
],
host_supported: true,
}
use std::sync::{Arc, Mutex};
use tokio::net::TcpStream;
use tokio::runtime::Runtime;
+use log::debug;
fn main() {
let sigint = install_sigint();
+ bt_common::init_logging();
let rt = Arc::new(Runtime::new().unwrap());
rt.block_on(async_main(Arc::clone(&rt), sigint));
}
extern "C" fn handle_sigint(_: i32) {
let mut sigint_tx = SIGINT_TX.lock().unwrap();
if let Some(tx) = &*sigint_tx {
- println!("Stopping gRPC root server due to SIGINT");
+ debug!("Stopping gRPC root server due to SIGINT");
tx.unbounded_send(()).unwrap();
}
*sigint_tx = None;
"libgddi",
"libcxx",
"liblazy_static",
+ "liblog_rust",
],
host_supported: true,
target: {
#[provides]
async fn provide_facade(hal_exports: HalExports, rt: Arc<Runtime>) -> HciHalFacadeService {
- println!("starting hal facade");
HciHalFacadeService {
rt,
cmd_tx: hal_exports.cmd_tx,
"libtokio",
"libprotobuf",
"libgddi",
+ "liblog_rust",
],
proc_macros: [
"libnum_derive",
use grpcio::*;
use std::sync::Arc;
use tokio::runtime::Runtime;
+use log::error;
module! {
facade_module,
let f = sink
.success(Empty::default())
.map_err(|e: grpcio::Error| {
- println!(
+ error!(
"failed to handle enqueue_command_with_complete request: {:?}",
e
)
let f = sink
.success(Empty::default())
.map_err(|e: grpcio::Error| {
- println!(
+ error!(
"failed to handle enqueue_command_with_status request: {:?}",
e
)
let f = sink
.success(Empty::default())
.map_err(|e: grpcio::Error| {
- println!(
+ error!(
"failed to handle enqueue_command_with_status request: {:?}",
e
)