about summary refs log tree commit diff
path: root/kittybox-rs
diff options
context:
space:
mode:
authorVika <vika@fireburn.ru>2023-07-09 01:32:31 +0300
committerVika <vika@fireburn.ru>2023-07-09 01:32:31 +0300
commit7724c54b4bd8edc9c9cca3e0ae1b459b4550e0fb (patch)
treea88c406d39c36210844d48d2edb7b9c7bb5e83e8 /kittybox-rs
parent46a37df2184851f6df35d85b479137caa7d6162b (diff)
downloadkittybox-7724c54b4bd8edc9c9cca3e0ae1b459b4550e0fb.tar.zst
main: use tracing_tree in debug builds
This gives me much more readable traces. JSON logging is still
superior in production, where logs are stored in systemd-journald and
preferably need to be self-contained lines.
Diffstat (limited to 'kittybox-rs')
-rw-r--r--kittybox-rs/Cargo.lock1
-rw-r--r--kittybox-rs/Cargo.toml1
-rw-r--r--kittybox-rs/src/main.rs10
3 files changed, 11 insertions, 1 deletions
diff --git a/kittybox-rs/Cargo.lock b/kittybox-rs/Cargo.lock
index 1934da0..36a785a 100644
--- a/kittybox-rs/Cargo.lock
+++ b/kittybox-rs/Cargo.lock
@@ -1498,6 +1498,7 @@ dependencies = [
  "tower",
  "tower-http",
  "tracing",
+ "tracing-log",
  "tracing-subscriber",
  "tracing-test",
  "tracing-tree",
diff --git a/kittybox-rs/Cargo.toml b/kittybox-rs/Cargo.toml
index c5aedf1..4c7670d 100644
--- a/kittybox-rs/Cargo.toml
+++ b/kittybox-rs/Cargo.toml
@@ -83,6 +83,7 @@ relative-path = "^1.5.0"     # Portable relative paths for Rust
 sha2 = "^0.9.8"              # SHA-2 series of algorithms for Rust
 tracing = { version = "0.1.34", features = [] }
 tracing-tree = "0.2.1"
+tracing-log = "0.1.3"
 tracing-subscriber = { version = "0.3.11", features = ["env-filter", "json"] }
 tower-http = { version = "0.3.3", features = ["trace", "cors", "catch-panic"] }
 tower = { version = "0.4.12", features = ["tracing"] }
diff --git a/kittybox-rs/src/main.rs b/kittybox-rs/src/main.rs
index 3136924..68d3b01 100644
--- a/kittybox-rs/src/main.rs
+++ b/kittybox-rs/src/main.rs
@@ -147,10 +147,18 @@ where
 #[tokio::main]
 async fn main() {
     use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter, Registry};
+
     Registry::default()
         .with(EnvFilter::from_default_env())
-        .with(tracing_subscriber::fmt::layer().json())
+        //.with(tracing_subscriber::fmt::layer().json())
+        .with(
+            #[cfg(debug_assertions)]
+            tracing_tree::HierarchicalLayer::new(2),
+            #[cfg(not(debug_assertions))]
+            tracing_subscriber::fmt::layer().json()
+        )
         .init();
+    //let _ = tracing_log::LogTracer::init();
 
     info!("Starting the kittybox server...");