Skip to content

Commit

Permalink
[Torii] Debug output of all indexed Events (#1464)
Browse files Browse the repository at this point in the history
* torii - Log events in debug!() as hex

* change debug!() for trace!()

* structured logging

* fix: fmt

---------

Co-authored-by: glihm <[email protected]>
  • Loading branch information
dubzn and glihm authored Feb 7, 2024
1 parent e2d5601 commit 58a50d1
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion crates/torii/core/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use starknet::providers::Provider;
use tokio::sync::broadcast::Sender;
use tokio::sync::mpsc::Sender as BoundedSender;
use tokio::time::sleep;
use tracing::{error, info, warn};
use tracing::{error, info, trace, warn};

use crate::processors::{BlockProcessor, EventProcessor, TransactionProcessor};
use crate::sql::Sql;
Expand Down Expand Up @@ -50,6 +50,11 @@ pub struct Engine<'db, P: Provider + Sync> {
block_tx: Option<BoundedSender<u64>>,
}

struct UnprocessedEvent {
keys: Vec<String>,
data: Vec<String>,
}

impl<'db, P: Provider + Sync> Engine<'db, P> {
pub fn new(
world: WorldContractReader<P>,
Expand Down Expand Up @@ -253,6 +258,17 @@ impl<'db, P: Provider + Sync> Engine<'db, P> {
processor
.process(&self.world, self.db, block, invoke_receipt, event_id, event)
.await?;
} else {
let unprocessed_event = UnprocessedEvent {
keys: event.keys.iter().map(|k| format!("{:#x}", k)).collect(),
data: event.data.iter().map(|d| format!("{:#x}", d)).collect(),
};

trace!(
keys = ?unprocessed_event.keys,
data = ?unprocessed_event.data,
"unprocessed event",
);
}
}
Ok(())
Expand Down

0 comments on commit 58a50d1

Please sign in to comment.