Skip to content

Commit 31b753c

Browse files
committed
test(p2p): improve tracing
- pass level via env var - display logs from libp2p
1 parent 910954b commit 31b753c

File tree

3 files changed

+30
-5
lines changed

3 files changed

+30
-5
lines changed

Cargo.lock

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node/testing/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ openmina-node-native = { path = "../../node/native" }
4141
reqwest = { version = "0.11.22", features = ["blocking", "json"] }
4242
temp-dir = "0.1.11"
4343
nix = { version = "0.27.1", features = ["process", "signal"] }
44+
tracing-log = "0.2.0"
4445

4546
[features]
4647
default = ["scenario-generators"]

node/testing/src/lib.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,21 @@ pub fn setup() -> tokio::runtime::Runtime {
3535
pub fn setup_without_rt() {
3636
lazy_static::lazy_static! {
3737
static ref INIT: () = {
38-
openmina_node_native::tracing::initialize(openmina_node_native::tracing::Level::WARN);
38+
let level = std::env::var("OPENMINA_TRACING_LEVEL").ok().and_then(|level| {
39+
match level.parse() {
40+
Ok(v) => Some(v),
41+
Err(e) => {
42+
eprintln!("cannot parse {level} as tracing level: {e}");
43+
None
44+
}
45+
}
46+
}).unwrap_or(openmina_node_native::tracing::Level::DEBUG);
47+
openmina_node_native::tracing::initialize(level);
48+
49+
if let Err(err) = tracing_log::LogTracer::init() {
50+
eprintln!("cannot initialize log tracing bridge: {err}");
51+
}
52+
3953
rayon::ThreadPoolBuilder::new()
4054
.num_threads(num_cpus::get().max(2) - 1)
4155
.thread_name(|i| format!("openmina_rayon_{i}"))
@@ -56,9 +70,7 @@ impl TestGate {
5670
async fn there_can_be_only_one() -> Self {
5771
Self(GATE.lock().await)
5872
}
59-
pub fn release(self) {
60-
61-
}
73+
pub fn release(self) {}
6274
}
6375

6476
pub async fn wait_for_other_tests() -> TestGate {

0 commit comments

Comments
 (0)