Use `tracing` crate for logs
This exposes any more structured `tracing` events that are logged within the Rust crates, while continuing to collect `log` records.
This commit is contained in:
parent
b4ffff9a78
commit
4c2bf6da69
|
@ -50,33 +50,6 @@ dependencies = [
|
|||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "0.7.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b4f55bd91a0978cbfd91c457a164bab8b4001c833b7f323132c0a4e1922dd44e"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "android_log-sys"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "85965b6739a430150bdd138e2374a98af0c3ee0d030b3bb7fc3bddff58d0102e"
|
||||
|
||||
[[package]]
|
||||
name = "android_logger"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b5e9dd62f37dea550caf48c77591dc50bd1a378ce08855be1a0c42a97b7550fb"
|
||||
dependencies = [
|
||||
"android_log-sys",
|
||||
"env_logger",
|
||||
"log",
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.66"
|
||||
|
@ -553,16 +526,6 @@ version = "1.8.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797"
|
||||
|
||||
[[package]]
|
||||
name = "env_logger"
|
||||
version = "0.9.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7"
|
||||
dependencies = [
|
||||
"log",
|
||||
"regex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "equihash"
|
||||
version = "0.2.0"
|
||||
|
@ -1015,6 +978,15 @@ version = "0.8.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a"
|
||||
|
||||
[[package]]
|
||||
name = "ndk-sys"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6e5a6ae77c8ee183dcbbba6150e2e6b9f3f4196a7666c02a715a95692ec1fa97"
|
||||
dependencies = [
|
||||
"jni-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nom"
|
||||
version = "7.1.1"
|
||||
|
@ -1031,6 +1003,16 @@ version = "0.7.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e9e591e719385e6ebaeb5ce5d3887f7d5676fceca6411d1925ccc95745f3d6f7"
|
||||
|
||||
[[package]]
|
||||
name = "nu-ansi-term"
|
||||
version = "0.46.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84"
|
||||
dependencies = [
|
||||
"overload",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-bigint"
|
||||
version = "0.4.3"
|
||||
|
@ -1126,6 +1108,12 @@ dependencies = [
|
|||
"zcash_note_encryption",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "overload"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
|
||||
|
||||
[[package]]
|
||||
name = "pairing"
|
||||
version = "0.22.0"
|
||||
|
@ -1135,6 +1123,20 @@ dependencies = [
|
|||
"group",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "paranoid-android"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e736c9fbaf42b43459cd1fded3dd272968daadfcbc5660ee231a12899f092289"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"ndk-sys",
|
||||
"sharded-slab",
|
||||
"smallvec",
|
||||
"tracing-core",
|
||||
"tracing-subscriber",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "password-hash"
|
||||
version = "0.3.2"
|
||||
|
@ -1433,8 +1435,6 @@ version = "1.7.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
|
@ -1665,6 +1665,15 @@ dependencies = [
|
|||
"opaque-debug 0.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sharded-slab"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.10.0"
|
||||
|
@ -1810,6 +1819,15 @@ dependencies = [
|
|||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thread_local"
|
||||
version = "1.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.2.27"
|
||||
|
@ -1906,6 +1924,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"valuable",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-log"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"log",
|
||||
"tracing-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-subscriber"
|
||||
version = "0.3.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a6176eae26dd70d0c919749377897b54a9276bd7061339665dd68777926b5a70"
|
||||
dependencies = [
|
||||
"nu-ansi-term",
|
||||
"sharded-slab",
|
||||
"smallvec",
|
||||
"thread_local",
|
||||
"tracing-core",
|
||||
"tracing-log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1969,6 +2013,12 @@ version = "1.2.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "422ee0de9031b5b948b97a8fc04e3aa35230001a722ddd27943e0be31564ce4c"
|
||||
|
||||
[[package]]
|
||||
name = "valuable"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
|
||||
|
||||
[[package]]
|
||||
name = "vcpkg"
|
||||
version = "0.2.15"
|
||||
|
@ -2117,17 +2167,18 @@ dependencies = [
|
|||
name = "zcash-android-wallet-sdk"
|
||||
version = "0.0.4"
|
||||
dependencies = [
|
||||
"android_logger",
|
||||
"failure",
|
||||
"hdwallet",
|
||||
"hdwallet-bitcoin",
|
||||
"hex",
|
||||
"jni",
|
||||
"log",
|
||||
"log-panics",
|
||||
"paranoid-android",
|
||||
"schemer",
|
||||
"secp256k1",
|
||||
"secrecy",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
"zcash_address",
|
||||
"zcash_client_backend",
|
||||
"zcash_client_sqlite",
|
||||
|
|
|
@ -11,14 +11,11 @@ edition = "2018"
|
|||
rust-version = "1.59"
|
||||
|
||||
[dependencies]
|
||||
android_logger = "0.11"
|
||||
failure = "0.1"
|
||||
hdwallet = "0.3.1"
|
||||
hdwallet-bitcoin = "0.3"
|
||||
hex = "0.4"
|
||||
jni = { version = "0.20", default-features = false }
|
||||
log = "0.4"
|
||||
log-panics = "2.0.0"
|
||||
schemer = "0.2"
|
||||
secp256k1 = "0.21"
|
||||
secrecy = "0.8"
|
||||
|
@ -28,6 +25,12 @@ zcash_client_sqlite = { version = "0.4", features = ["transparent-inputs", "unst
|
|||
zcash_primitives = "0.9"
|
||||
zcash_proofs = "0.9"
|
||||
|
||||
# Logging
|
||||
log-panics = "2.0.0"
|
||||
paranoid-android = "0.2"
|
||||
tracing = "0.1"
|
||||
tracing-subscriber = "0.3"
|
||||
|
||||
## Uncomment this to test librustzcash changes locally
|
||||
#[patch.crates-io]
|
||||
#zcash_address = { path = '../../clones/librustzcash/components/zcash_address' }
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::convert::{TryFrom, TryInto};
|
||||
use std::panic;
|
||||
use std::path::Path;
|
||||
use std::ptr;
|
||||
|
||||
use android_logger::Config;
|
||||
use failure::format_err;
|
||||
use jni::objects::{JObject, JValue};
|
||||
use jni::{
|
||||
|
@ -15,9 +11,10 @@ use jni::{
|
|||
sys::{jboolean, jbyteArray, jint, jlong, jobject, jobjectArray, jstring, JNI_FALSE, JNI_TRUE},
|
||||
JNIEnv,
|
||||
};
|
||||
use log::Level;
|
||||
use schemer::MigratorError;
|
||||
use secrecy::{ExposeSecret, SecretVec};
|
||||
use tracing::{debug, error};
|
||||
use tracing_subscriber::prelude::*;
|
||||
use zcash_address::{ToAddress, ZcashAddress};
|
||||
use zcash_client_backend::keys::{DecodingError, UnifiedSpendingKey};
|
||||
use zcash_client_backend::{
|
||||
|
@ -101,16 +98,23 @@ pub unsafe extern "C" fn Java_cash_z_ecc_android_sdk_jni_RustBackend_initLogs(
|
|||
_env: JNIEnv<'_>,
|
||||
_: JClass<'_>,
|
||||
) {
|
||||
android_logger::init_once(
|
||||
Config::default()
|
||||
.with_min_level(Level::Debug)
|
||||
.with_tag("cash.z.rust.logs"),
|
||||
);
|
||||
// Set up the Android tracing layer.
|
||||
#[cfg(target_os = "android")]
|
||||
let android_layer = paranoid_android::layer("cash.z.rust.logs")
|
||||
.with_ansi(false)
|
||||
.with_filter(tracing_subscriber::filter::LevelFilter::DEBUG);
|
||||
|
||||
// Install the `tracing` subscriber.
|
||||
let registry = tracing_subscriber::registry();
|
||||
#[cfg(target_os = "android")]
|
||||
let registry = registry.with(android_layer);
|
||||
registry.init();
|
||||
|
||||
// Log panics instead of writing them to stderr.
|
||||
log_panics::init();
|
||||
|
||||
debug!("logs have been initialized successfully");
|
||||
print_debug_state()
|
||||
print_debug_state();
|
||||
}
|
||||
|
||||
/// Sets up the internal structure of the data database.
|
||||
|
|
|
@ -16,6 +16,7 @@ use failure::Error;
|
|||
use jni::JNIEnv;
|
||||
use std::any::Any;
|
||||
use std::thread;
|
||||
use tracing::error;
|
||||
|
||||
type ExceptionResult<T> = thread::Result<Result<T, Error>>;
|
||||
|
||||
|
|
Loading…
Reference in New Issue