Skip to content

Commit

Permalink
Improve logging in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
romac committed Jan 10, 2025
1 parent 47f994c commit 83c5eed
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
13 changes: 12 additions & 1 deletion code/crates/engine/src/wal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ where
type Arguments = Args<Codec>;
type State = State<Ctx>;

#[tracing::instrument(
name = "wal.pre_start",
parent = &self.span,
skip_all,
)]
async fn pre_start(
&self,
_myself: WalRef<Ctx>,
Expand All @@ -196,7 +201,7 @@ where
let (tx, rx) = mpsc::channel(100);

// Spawn a system thread to perform blocking WAL operations.
let handle = self::thread::spawn(tracing::Span::current(), log, args.codec, rx);
let handle = self::thread::spawn(self.span.clone(), log, args.codec, rx);

Ok(State {
height: Ctx::Height::default(),
Expand Down Expand Up @@ -224,6 +229,12 @@ where
Ok(())
}

#[tracing::instrument(
name = "wal.post_stop",
parent = &self.span,
skip_all,
fields(height = %state.height),
)]
async fn post_stop(
&self,
_: WalRef<Ctx>,
Expand Down
4 changes: 2 additions & 2 deletions code/crates/test/framework/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -636,9 +636,9 @@ pub fn init_logging(test_module: &str) {
.any(|(k, v)| std::env::var(k).as_deref() == Ok(v));

let directive = if enable_debug {
format!("{test_module}=debug,ractor=error,debug")
format!("{test_module}=debug,informalsystems_malachitebft=trace,informalsystems_malachitebft_discovery=error,libp2p=warn,ractor=warn")
} else {
format!("{test_module}=debug,ractor=error,warn")
format!("{test_module}=debug,informalsystems_malachitebft=info,informalsystems_malachitebft_discovery=error,libp2p=warn,ractor=warn")
};

let filter = EnvFilter::builder().parse(directive).unwrap();
Expand Down

0 comments on commit 83c5eed

Please sign in to comment.