From 89ae4c6cf6a28933f3bed69401abd205878862ed Mon Sep 17 00:00:00 2001 From: Paul Wagner Date: Sun, 28 Apr 2024 22:28:38 +0200 Subject: [PATCH] use json format for structured logging --- Cargo.lock | 13 +++++++++++++ Cargo.toml | 2 +- src/main.rs | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7bd003f..6d8e987 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3204,6 +3204,16 @@ dependencies = [ "tracing-core", ] +[[package]] +name = "tracing-serde" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc6b213177105856957181934e4920de57730fc69bf42c37ee5bb664d406d9e1" +dependencies = [ + "serde", + "tracing-core", +] + [[package]] name = "tracing-subscriber" version = "0.3.18" @@ -3211,11 +3221,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" dependencies = [ "nu-ansi-term", + "serde", + "serde_json", "sharded-slab", "smallvec", "thread_local", "tracing-core", "tracing-log", + "tracing-serde", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 305190a..a7025f2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,7 +39,7 @@ prometheus = { version = "0.13" } futures-util = "0.3.30" config = "0.14.0" tracing = "0.1.40" -tracing-subscriber = "0.3.18" +tracing-subscriber = { version = "0.3.18", features = ["json"] } sentry = { version = "0.32.2", default-features = false, features = ["backtrace", "contexts", "panic", "debug-images", "reqwest", "rustls", "tower"] } sentry-tracing = "0.32.2" moka = { version = "0.12.5", features = ["future"] } diff --git a/src/main.rs b/src/main.rs index 7faf5a0..7a72c4a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,7 +29,7 @@ fn main() -> Result<(), Box> { tracing_subscriber::registry() .with( tracing_subscriber::fmt::layer() - .compact() + .json() .with_filter(settings.logging.level), ) .with(sentry_tracing::layer())