From d9621cf95201c7a64a365686201f40bbd5952156 Mon Sep 17 00:00:00 2001 From: sommerfeld Date: Wed, 24 Apr 2024 01:51:51 +0100 Subject: Improve log format consistency --- src/actions.rs | 18 ++++++++++++++---- src/main.rs | 6 +++++- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/actions.rs b/src/actions.rs index 7979bd7..0daec15 100644 --- a/src/actions.rs +++ b/src/actions.rs @@ -108,10 +108,10 @@ pub async fn get_actions<'a>( // TODO: parallelize this. It's hard because the result vector needs to be shared. for action_config in actions_config { - debug!("registering action '{}'", action_config); + debug!("[{}] registering action", action_config); match get_action(message_config, action_config).await { Ok(action) => { - info!("registered action '{}'", action_config); + info!("[{}] registered action", action_config); result.push(action); } Err(e) => { @@ -127,10 +127,20 @@ pub async fn run_actions( actions: &[&(dyn Action<'_> + Sync)], params: Option>, ) { + let params_ref = params.as_ref(); TokioScope::scope_and_block(|s| { for &action in actions { - debug!("running '{}' action", action.name()); - s.spawn(action.run(params.as_ref())); + s.spawn(async { + info!( + "[{}][{}][{}] running", + params_ref.map(|p| p.wallet()).unwrap_or("wallet"), + params_ref + .map(|p| p.txid_short()) + .unwrap_or("txid".to_string()), + action.name() + ); + action.run(params_ref); + }); } }); } diff --git a/src/main.rs b/src/main.rs index f719433..14b660c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -74,7 +74,11 @@ async fn get_and_handle_new_txs( TokioScope::scope_and_block(|s| { for tx in txs.iter() { let params = MessageParams::new(tx, &locked_wallet_info); - info!("running actions for txid '{}'", params.txid_short()); + info!( + "[{}][{}] running actions", + params.wallet(), + params.txid_short() + ); s.spawn(run_actions(actions, Some(params))); } }); -- cgit v1.2.3-70-g09d2