Skip to content

Commit

Permalink
Add json logging format.
Browse files Browse the repository at this point in the history
  • Loading branch information
0xSasaPrsic authored and QEDK committed Mar 13, 2024
1 parent 0367fc4 commit f16974b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 4 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Message>,
}

Expand Down Expand Up @@ -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")],
Expand Down Expand Up @@ -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
})),
)
Expand Down Expand Up @@ -510,7 +511,7 @@ async fn get_avl_head(State(state): State<Arc<AppState>>) -> 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()
Expand Down

0 comments on commit f16974b

Please sign in to comment.