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

Commit afca803d authored by Howard Chung's avatar Howard Chung Committed by Yun-hao Chung
Browse files

Floss: Print log when rust panic

This imports log_panics to print log when panic! is reached.
An example of the log is:
thread 'main' panicked at 'xxx': system/gd/rust/linux/stack/src/
bluetooth_admin.rs:118

Bug: 295133385
Test: mma -j32
Test: locally modify the code to trigger panic and verify the log is in
/var/log/bluetooth.log
Tag: #floss

Change-Id: I217ccd30542c5e429abfcd58626a251307353049
parent 818bd8ce
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ rand = { version = "0.8.3", features = ["small_rng"] }
serde_json = "1.0"
syslog = "6"
tokio = { version = "1", features = ['bytes', 'fs', 'io-util', 'libc', 'macros', 'mio', 'net', 'num_cpus', 'rt', 'rt-multi-thread', 'sync', 'time', 'tokio-macros'] }
log-panics = "2.1.0"

[lib]
path = "src/lib.rs"
+3 −0
Original line number Diff line number Diff line
@@ -2,6 +2,8 @@ use bt_common::init_flags;
use log::LevelFilter;
use syslog::{BasicLogger, Facility, Formatter3164};

use log_panics;

/// API to modify log levels.
pub trait IBluetoothLogging {
    /// Check whether debug logging is enabled.
@@ -33,6 +35,7 @@ impl BluetoothLogging {
            let logger = syslog::unix(formatter).expect("could not connect to syslog");
            let _ = log::set_boxed_logger(Box::new(BasicLogger::new(logger)))
                .map(|()| log::set_max_level(level));
            log_panics::init();
        }

        Self { is_debug }