diff --git a/Cargo.lock b/Cargo.lock index c8da6a5..1bf5e4d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5387,12 +5387,15 @@ dependencies = [ "nu-ansi-term", "once_cell", "regex", + "serde", + "serde_json", "sharded-slab", "smallvec", "thread_local", "tracing", "tracing-core", "tracing-log 0.2.0", + "tracing-serde", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 8ead94f..e24cfb3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ sha3 = "0.10.8" tokio = { version = "1.35.1", features = ["macros", "rt-multi-thread", "parking_lot"] } tower-http = { version = "0.5.0", features = ["trace", "compression-br"] } tracing = "0.1.40" -tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } +tracing-subscriber = { version = "0.3.18", features = ["env-filter", "json"] } sp-io = "32.0.0" sp-core = "30.0.0" chrono = "0.4.34" diff --git a/src/main.rs b/src/main.rs index be08867..e8e2c94 100644 --- a/src/main.rs +++ b/src/main.rs @@ -53,6 +53,7 @@ struct IndexStruct { #[serde(rename_all = "camelCase")] struct KateQueryDataProofV2Response { data_proof: DataProof, + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] message: Option, } @@ -204,7 +205,7 @@ async fn get_eth_proof( Ok(resp) => match resp { Ok(data) => data, Err(err) => { - tracing::error!("❌ {:?}", err); + tracing::error!("❌ Cannot query data proof {:?}", err); return ( StatusCode::BAD_REQUEST, [("Cache-Control", "max-age=300, must-revalidate")], @@ -279,7 +280,7 @@ async fn get_eth_proof( blob_root: data_proof_res.data_proof.blob_root, bridge_root: data_proof_res.data_proof.bridge_root, data_root_commitment: succinct_data.data_commitment, - block_hash: block_hash, + block_hash, message: data_proof_res.message })), ) @@ -510,7 +511,7 @@ async fn get_avl_head(State(state): State>) -> impl IntoResponse { async fn main() { dotenvy::dotenv().ok(); tracing_subscriber::registry() - .with(tracing_subscriber::fmt::layer()) + .with(tracing_subscriber::fmt::layer().json()) .with( tracing_subscriber::EnvFilter::try_from_default_env().unwrap_or_else(|_| { "bridge_api=debug,tower_http=debug,axum::rejection=trace".into()