Skip to content

Commit cad3330

Browse files
committed
merge: fix conflicts
2 parents 309b952 + d9c3aeb commit cad3330

File tree

13 files changed

+119
-19
lines changed

13 files changed

+119
-19
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,4 @@ workspace = true
7474

7575
[features]
7676
test-utils = []
77+
tracing = []

src/block_range_scanner.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,9 @@ use crate::{
100100
use alloy::{
101101
consensus::BlockHeader,
102102
eips::{BlockId, BlockNumberOrTag},
103-
network::{BlockResponse, Network, primitives::HeaderResponse},
103+
network::{BlockResponse, Network},
104104
primitives::BlockNumber,
105105
};
106-
use tracing::{error, info, warn};
107106

108107
mod common;
109108
mod range_iterator;
@@ -353,7 +352,7 @@ impl<N: Network> Service<N> {
353352
cmd = self.command_receiver.recv() => {
354353
if let Some(command) = cmd {
355354
if let Err(e) = self.handle_command(command).await {
356-
error!("Command handling error: {}", e);
355+
error!(error = %e, "Command handling error");
357356
self.error_count += 1;
358357
}
359358
} else {
@@ -603,7 +602,7 @@ impl<N: Network> Service<N> {
603602
let common_ancestor = common_ancestor.header().number();
604603
info!(
605604
block_number = %tip_number,
606-
hash = %tip.header().hash(),
605+
hash = %alloy::network::primitives::HeaderResponse::hash(tip.header()),
607606
common_ancestor = %common_ancestor,
608607
"Reorg detected"
609608
);

src/block_range_scanner/common.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use alloy::{
1313
network::{BlockResponse, Network},
1414
primitives::BlockNumber,
1515
};
16-
use tracing::{error, info, warn};
1716

1817
#[allow(clippy::too_many_arguments)]
1918
pub(crate) async fn stream_live_blocks<N: Network>(

src/block_range_scanner/range_iterator.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use alloy::primitives::BlockNumber;
22
use std::{marker::PhantomData, ops::RangeInclusive};
3-
use tracing::debug;
43

54
pub struct Forward;
65
pub struct Reverse;

src/block_range_scanner/reorg_handler.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use alloy::{
44
network::{BlockResponse, Ethereum, Network, primitives::HeaderResponse},
55
primitives::BlockHash,
66
};
7-
use tracing::{info, warn};
87

98
use crate::{
109
ScannerError,

src/block_range_scanner/sync_handler.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use alloy::{eips::BlockId, network::Network, primitives::BlockNumber};
22
use tokio::sync::mpsc;
3-
use tracing::{error, info};
43

54
use crate::{
65
Notification, ScannerError,

src/event_scanner/scanner/common.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use tokio::{
2020
task::JoinSet,
2121
};
2222
use tokio_stream::{Stream, wrappers::ReceiverStream};
23-
use tracing::{debug, error, info, trace, warn};
2423

2524
#[derive(Copy, Clone, Debug)]
2625
pub(crate) enum ConsumerMode {

src/event_scanner/scanner/sync/from_latest.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
use alloy::{eips::BlockNumberOrTag, network::Network};
22

3-
use tracing::{error, info};
4-
53
use crate::{
64
EventScannerBuilder, ScannerError,
75
event_scanner::{

src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,11 @@
4747
//! retry and fail over across multiple RPC endpoints.
4848
//!
4949
//! [finalized]: alloy::eips::BlockNumberOrTag::Finalized
50-
pub mod block_range_scanner;
5150
51+
#[macro_use]
52+
mod logging;
53+
54+
pub mod block_range_scanner;
5255
pub mod robust_provider;
5356
#[cfg(any(test, feature = "test-utils"))]
5457
pub mod test_utils;

src/logging.rs

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
#[cfg(feature = "tracing")]
2+
#[allow(unused_macros)]
3+
macro_rules! error {
4+
($($arg:tt)*) => {
5+
tracing::error!($($arg)*)
6+
};
7+
}
8+
9+
#[cfg(not(feature = "tracing"))]
10+
#[allow(unused_macros)]
11+
macro_rules! error {
12+
($($arg:tt)*) => {
13+
$crate::__trace_consume!($($arg)*)
14+
};
15+
}
16+
17+
#[cfg(feature = "tracing")]
18+
#[allow(unused_macros)]
19+
macro_rules! warn {
20+
($($arg:tt)*) => {
21+
tracing::warn!($($arg)*)
22+
};
23+
}
24+
25+
#[cfg(not(feature = "tracing"))]
26+
#[allow(unused_macros)]
27+
macro_rules! warn {
28+
($($arg:tt)*) => {
29+
$crate::__trace_consume!($($arg)*)
30+
};
31+
}
32+
33+
#[cfg(feature = "tracing")]
34+
#[allow(unused_macros)]
35+
macro_rules! info {
36+
($($arg:tt)*) => {
37+
tracing::info!($($arg)*)
38+
};
39+
}
40+
41+
#[cfg(not(feature = "tracing"))]
42+
#[allow(unused_macros)]
43+
macro_rules! info {
44+
($($arg:tt)*) => {
45+
$crate::__trace_consume!($($arg)*)
46+
};
47+
}
48+
49+
#[cfg(feature = "tracing")]
50+
#[allow(unused_macros)]
51+
macro_rules! debug {
52+
($($arg:tt)*) => {
53+
tracing::debug!($($arg)*)
54+
};
55+
}
56+
57+
#[cfg(not(feature = "tracing"))]
58+
#[allow(unused_macros)]
59+
macro_rules! debug {
60+
($($arg:tt)*) => {
61+
$crate::__trace_consume!($($arg)*)
62+
};
63+
}
64+
65+
#[cfg(feature = "tracing")]
66+
#[allow(unused_macros)]
67+
macro_rules! trace {
68+
($($arg:tt)*) => {
69+
tracing::trace!($($arg)*)
70+
};
71+
}
72+
73+
#[cfg(not(feature = "tracing"))]
74+
#[allow(unused_macros)]
75+
macro_rules! trace {
76+
($($arg:tt)*) => {
77+
$crate::__trace_consume!($($arg)*)
78+
};
79+
}
80+
81+
#[doc(hidden)]
82+
#[macro_export]
83+
#[cfg(not(feature = "tracing"))]
84+
#[allow(unused_macros)]
85+
macro_rules! __trace_consume {
86+
// field = %expr, rest...
87+
($field:ident = % $value:expr, $($rest:tt)*) => {
88+
{ let _ = &$value; $crate::__trace_consume!($($rest)*); }
89+
};
90+
// field = ?expr, rest...
91+
($field:ident = ? $value:expr, $($rest:tt)*) => {
92+
{ let _ = &$value; $crate::__trace_consume!($($rest)*); }
93+
};
94+
// field = expr, rest...
95+
($field:ident = $value:expr, $($rest:tt)*) => {
96+
{ let _ = &$value; $crate::__trace_consume!($($rest)*); }
97+
};
98+
// String literal or other tokens - ignore
99+
($lit:literal $($rest:tt)*) => {
100+
$crate::__trace_consume!($($rest)*)
101+
};
102+
// Base case - empty
103+
() => {};
104+
}

0 commit comments

Comments
 (0)