0xPolygonZero / zk_evm

Apache License 2.0
86 stars 38 forks source link

Replace all logging with tracing #668

Open einar-polygon opened 2 months ago

einar-polygon commented 2 months ago

Currently our project is using a mix of logging and tracing. Since tracing works as a drop-in replacement, so it shouldn't be too much work, and would provide benefits such as a more pleasant debugging experience.

$ rg "log[^y]|tracing" **/Cargo.toml

proof_gen/Cargo.toml
13:log = { workspace = true }

evm_arithmetization/Cargo.toml
20:env_logger = { workspace = true }
26:log = { workspace = true }

mpt_trie/Cargo.toml
22:log = { workspace = true }
35:pretty_env_logger = { workspace = true }

Cargo.toml
57:env_logger = "0.11.3"
70:log = "0.4.21"
82:pretty_env_logger = "0.5.0"
101:tracing = { version = "0.1", features = ["attributes"] }
102:tracing-subscriber = { version = "0.3", features = ["env-filter"] }

trace_decoder/Cargo.toml
29:log = { workspace = true }
58:pretty_env_logger = { workspace = true }

zero/Cargo.toml
42:tracing = { workspace = true }
43:tracing-subscriber = { workspace = true }
0xaatif commented 2 months ago

Let's also start using structured logging instead of string interpolation as we do this

Nashtare commented 1 month ago

I'll be handling this in parallel of the replacement of TimingTree with tracing::instrument on the plonky2 side

0xaatif commented 1 month ago

Robin, you might find this helpful: https://github.com/aatifsyed/synsert/blob/main/examples/tracing.rs

It takes string interpolated logs like info!("couldn't load block number {block_number}") and creates structured logs like info!(%block_number, "couldn't load block number")

atanmarko commented 1 month ago

@Nashtare You should probably move zero/src/tracing.rs to common/src/tracing.rs so that we can easily manage tracing setup and initialization in one place.