Skip to content

Commit cc129dd

Browse files
authored
feat: 🔊 Add success logs to all tasks and RPCs (#591)
* feat: 🔊 Add success logs to all tasks * feat: 🔊 Minor improvements in logs * feat: 🔊 Add end logs to RPC calls
1 parent 116dea1 commit cc129dd

24 files changed

+529
-166
lines changed

client/actors-framework/src/event_bus.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use anyhow::Result;
2-
use sc_tracing::tracing::{error, warn};
2+
use sc_tracing::tracing::{error, info, warn};
33
use std::sync::Arc;
44
use tokio::sync::{broadcast, Semaphore};
55

@@ -47,7 +47,15 @@ pub trait ProvidesEventBus<T: EventBusMessage> {
4747
}
4848

4949
pub trait EventHandler<E: EventBusMessage>: Clone + Send + 'static {
50-
fn handle_event(&mut self, event: E) -> impl std::future::Future<Output = Result<()>> + Send;
50+
/// Handle a single event.
51+
///
52+
/// On success, returns a human-readable message that will be logged centrally by the
53+
/// event bus listener. This encourages each handler to provide a meaningful success
54+
/// description.
55+
fn handle_event(
56+
&mut self,
57+
event: E,
58+
) -> impl std::future::Future<Output = Result<String>> + Send;
5159

5260
fn subscribe_to_provider<EP: ProvidesEventBus<E>>(
5361
self,
@@ -112,7 +120,9 @@ impl<T: EventBusMessage, E: EventHandler<T> + Send + 'static> EventBusListener<T
112120
.expect("To acquire the permit");
113121
self.spawner.spawn(async move {
114122
match cloned_event_handler.handle_event(event).await {
115-
Ok(_) => {}
123+
Ok(msg) => {
124+
info!("Task completed successfully: {}", msg);
125+
}
116126
Err(error) => {
117127
warn!("Task ended with error: {:?}", error);
118128
}

client/forest-manager/src/traits.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub trait ForestStorage<T: TrieLayout, Runtime: StorageEnableRuntime>: 'static {
4848
#[async_trait]
4949
pub trait ForestStorageHandler<Runtime: StorageEnableRuntime> {
5050
/// The key type used to identify forest storage instances.
51-
type Key: From<Vec<u8>> + Debug + Send + Sync;
51+
type Key: From<Vec<u8>> + AsRef<[u8]> + Debug + Send + Sync;
5252
/// Type representing the forest storage instance.
5353
type FS: ForestStorage<StorageProofsMerkleTrieLayout, Runtime> + Send + Sync;
5454

0 commit comments

Comments
 (0)