Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 492ddce7 authored by Zach Johnson's avatar Zach Johnson
Browse files

rusty-gd: integrate logging

Bug: 171749953
Tag: #gd-refactor
Test: gd/cert/run --rhost SimpleHalTest
Change-Id: Ic0e454d8490d08a645bbab86f86f102c0d7784ad
parent 43c0482b
Loading
Loading
Loading
Loading
+15 −0
Original line number Original line Diff line number Diff line
@@ -6,7 +6,20 @@ rust_library {
    rustlibs: [
    rustlibs: [
        "libtokio",
        "libtokio",
        "libnix",
        "libnix",
        "liblog_rust",
    ],
    ],
    target: {
        android: {
            rustlibs: [
                "libandroid_logger",
            ],
        },
        host: {
            rustlibs: [
                "libenv_logger",
            ],
        },
    },
    host_supported: true,
    host_supported: true,
}
}


@@ -18,5 +31,7 @@ rust_test_host {
    rustlibs: [
    rustlibs: [
        "libtokio",
        "libtokio",
        "libnix",
        "libnix",
        "liblog_rust",
        "libenv_logger",
    ],
    ],
}
}
+19 −0
Original line number Original line Diff line number Diff line
@@ -9,3 +9,22 @@ mod ready;
#[cfg(test)]
#[cfg(test)]
#[macro_use]
#[macro_use]
mod asserts;
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();
}
+2 −0
Original line number Original line Diff line number Diff line
@@ -28,6 +28,8 @@ rust_binary {
      "libgrpcio",
      "libgrpcio",
      "libtokio",
      "libtokio",
      "libnix",
      "libnix",
      "libbt_common",
      "liblog_rust",
    ],
    ],
    host_supported: true,
    host_supported: true,
}
}
+3 −1
Original line number Original line Diff line number Diff line
@@ -17,9 +17,11 @@ use std::net::{IpAddr, Ipv4Addr, Shutdown, SocketAddr};
use std::sync::{Arc, Mutex};
use std::sync::{Arc, Mutex};
use tokio::net::TcpStream;
use tokio::net::TcpStream;
use tokio::runtime::Runtime;
use tokio::runtime::Runtime;
use log::debug;


fn main() {
fn main() {
    let sigint = install_sigint();
    let sigint = install_sigint();
    bt_common::init_logging();
    let rt = Arc::new(Runtime::new().unwrap());
    let rt = Arc::new(Runtime::new().unwrap());
    rt.block_on(async_main(Arc::clone(&rt), sigint));
    rt.block_on(async_main(Arc::clone(&rt), sigint));
}
}
@@ -106,7 +108,7 @@ lazy_static! {
extern "C" fn handle_sigint(_: i32) {
extern "C" fn handle_sigint(_: i32) {
    let mut sigint_tx = SIGINT_TX.lock().unwrap();
    let mut sigint_tx = SIGINT_TX.lock().unwrap();
    if let Some(tx) = &*sigint_tx {
    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();
        tx.unbounded_send(()).unwrap();
    }
    }
    *sigint_tx = None;
    *sigint_tx = None;
+1 −0
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@ rust_library {
        "libgddi",
        "libgddi",
        "libcxx",
        "libcxx",
        "liblazy_static",
        "liblazy_static",
        "liblog_rust",
    ],
    ],
    host_supported: true,
    host_supported: true,
    target: {
    target: {
Loading