Skip to content

Commit 19893e4

Browse files
committed
Fix logging
1 parent 828c985 commit 19893e4

File tree

3 files changed

+29
-12
lines changed

3 files changed

+29
-12
lines changed

code/crates/test/app/src/app.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ pub async fn run(
8888
// then we would need to respect the timeout and stop at a certain point.
8989

9090
info!(%height, %round, "Consensus is requesting a value to propose");
91-
92-
dbg!(state.ctx.middleware());
91+
tracing::debug!(%height, %round, "Middleware: {:?}", state.ctx.middleware());
9392

9493
// Here it is important that, if we have previously built a value for this height and round,
9594
// we send back the very same value.

code/crates/test/framework/src/logging.rs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,29 @@ pub fn init_logging() {
22
use tracing_subscriber::util::SubscriberInitExt;
33
use tracing_subscriber::{EnvFilter, FmtSubscriber};
44

5-
let crate_name = env!("CARGO_CRATE_NAME");
65
let debug_vars = &[("ACTIONS_RUNNER_DEBUG", "true"), ("MALACHITE_DEBUG", "1")];
76
let enable_debug = debug_vars
87
.iter()
98
.any(|(k, v)| std::env::var(k).as_deref() == Ok(v));
109

11-
let trace_level = if enable_debug { "trace" } else { "info" };
12-
let directive = format!(
13-
"{crate_name}=debug,informalsystems_malachitebft={trace_level},informalsystems_malachitebft_discovery=error,libp2p=warn,ractor=warn"
14-
);
10+
let trace_level = if enable_debug { "debug" } else { "info" };
11+
12+
let directives = &[
13+
("informalsystems_malachitebft", trace_level),
14+
(env!("CARGO_CRATE_NAME"), "debug"),
15+
("it", "debug"), // Name of the integration test crate
16+
("informalsystems_malachitebft_test", "debug"),
17+
("informalsystems_malachitebft_test_app", "debug"),
18+
("informalsystems_malachitebft_discovery", "error"),
19+
("libp2p", "warn"),
20+
("ractor", "warn"),
21+
];
22+
23+
let directive = directives
24+
.iter()
25+
.map(|(target, level)| format!("{target}={level}"))
26+
.collect::<Vec<_>>()
27+
.join(",");
1528

1629
let filter = EnvFilter::builder().parse(directive).unwrap();
1730

code/crates/test/tests/it/wal.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -462,14 +462,19 @@ impl Middleware for ByzantineProposer {
462462
proposal: &mut LocallyProposedValue<TestContext>,
463463
reproposal: bool,
464464
) {
465+
use informalsystems_malachitebft_test::Value;
466+
use rand::Rng;
467+
465468
if !reproposal {
469+
tracing::warn!(
470+
"ByzantineProposer: First time proposing value {:}",
471+
proposal.value.id()
472+
);
473+
466474
// Do not change the value if it is the first time we propose it
467475
return;
468476
}
469477

470-
use informalsystems_malachitebft_test::Value;
471-
use rand::Rng;
472-
473478
// Make up a new value that is different from the one we are supposed to propose
474479
let new_value = loop {
475480
let new_value = Value::new(rand::thread_rng().gen_range(100..=100000));
@@ -478,8 +483,8 @@ impl Middleware for ByzantineProposer {
478483
}
479484
};
480485

481-
tracing::error!(
482-
"XXX Not re-using previously built value {:} but a new one {:}",
486+
tracing::warn!(
487+
"ByzantineProposer: Not re-using previously built value {:} but a new one {:}",
483488
proposal.value.id(),
484489
new_value.id()
485490
);

0 commit comments

Comments
 (0)