Skip to content

Commit f2dea36

Browse files
committed
logging: migrate from log to tracing crate
1 parent 32f99f9 commit f2dea36

File tree

11 files changed

+173
-76
lines changed

11 files changed

+173
-76
lines changed

Cargo.lock

Lines changed: 131 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ bitcoin = "0.30.1"
1515
byteorder = "1.4.3"
1616
clap = { version = "4.3.19", features = [ "cargo" ] }
1717
dirs = "5.0.1"
18-
env_logger = "0.10.0"
1918
hex = "0.4.3"
20-
log = { version = "0.4.19", default-features = false, features = ["std"] }
2119
rusty-leveldb = "2.0.0"
20+
tracing = { version = "0.1.37", default-features = false }
21+
tracing-subscriber = { version = "0.3.17", features = [ "env-filter", "fmt", "ansi", "tracing-log" ], default-features = false }
2222

2323
[dev-dependencies]
2424
tempfile = "3.7.0"

src/callbacks/balances.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl Callback for Balances {
5555

5656
fn on_start(&mut self, block_height: u64) -> anyhow::Result<()> {
5757
self.start_height = block_height;
58-
log::info!(target: "callback", "Executing balances with dump folder: {} ...", &self.dump_folder.display());
58+
tracing::info!(target: "callback", "Executing balances with dump folder: {} ...", &self.dump_folder.display());
5959
Ok(())
6060
}
6161

@@ -101,7 +101,7 @@ impl Callback for Balances {
101101
)
102102
.expect("Unable to rename tmp file!");
103103

104-
log::info!(target: "callback", "Done.\nDumped {} addresses.", balances.len());
104+
tracing::info!(target: "callback", "Done.\nDumped {} addresses.", balances.len());
105105
Ok(())
106106
}
107107
}

src/callbacks/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl UnspentsTracker {
8181
count += 1;
8282
}
8383
Err(_) => {
84-
log::debug!(
84+
tracing::debug!(
8585
target: "callback", "Ignoring invalid utxo in: {}",
8686
tx.txid(),
8787
);

src/callbacks/opreturn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ impl Callback for OpReturn {
2424
}
2525

2626
fn on_start(&mut self, _: u64) -> anyhow::Result<()> {
27-
log::info!(target: "callback", "Executing OpReturn ...");
27+
tracing::info!(target: "callback", "Executing OpReturn ...");
2828
Ok(())
2929
}
3030

src/callbacks/simplestats.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ impl Callback for SimpleStats {
192192
}
193193

194194
fn on_start(&mut self, _: u64) -> anyhow::Result<()> {
195-
log::info!(target: "callback", "Executing simplestats ...");
195+
tracing::info!(target: "callback", "Executing simplestats ...");
196196
Ok(())
197197
}
198198

@@ -258,7 +258,7 @@ impl Callback for SimpleStats {
258258
self.print_averages(&mut buffer)?;
259259
writeln!(&mut buffer)?;
260260
self.print_transaction_types(&mut buffer)?;
261-
log::info!(target: "simplestats", "\n\n{}", String::from_utf8_lossy(&buffer));
261+
tracing::info!(target: "simplestats", "\n\n{}", String::from_utf8_lossy(&buffer));
262262
Ok(())
263263
}
264264
}

src/callbacks/unspentcsvdump.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl crate::callbacks::Callback for UnspentCsvDump {
5757

5858
fn on_start(&mut self, block_height: u64) -> anyhow::Result<()> {
5959
self.start_height = block_height;
60-
log::info!(target: "callback", "Executing unspentcsvdump with dump folder: {} ...", &self.dump_folder.display());
60+
tracing::info!(target: "callback", "Executing unspentcsvdump with dump folder: {} ...", &self.dump_folder.display());
6161
Ok(())
6262
}
6363

@@ -103,7 +103,7 @@ impl crate::callbacks::Callback for UnspentCsvDump {
103103
)),
104104
)?;
105105

106-
log::info!(target: "callback", "Done.\nDumped blocks from height {} to {}:\n\
106+
tracing::info!(target: "callback", "Done.\nDumped blocks from height {} to {}:\n\
107107
\t-> transactions: {:9}\n\
108108
\t-> inputs: {:9}\n\
109109
\t-> outputs: {:9}",

0 commit comments

Comments
 (0)