From f4ef23a28ec9e566796a8112b08809ad0c998f0e Mon Sep 17 00:00:00 2001 From: Devdutt Shenoi Date: Thu, 21 Nov 2024 11:41:31 +0530 Subject: [PATCH 1/3] feat: `env_logger` ~> `tracing_subscriber` --- Cargo.lock | 130 +++++++++++++++++++++++++++++++++++---------- server/Cargo.toml | 2 +- server/src/main.rs | 5 +- 3 files changed, 106 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b5dc1dd51..428eaeae0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -672,7 +672,7 @@ dependencies = [ "memchr", "num", "regex", - "regex-syntax", + "regex-syntax 0.8.5", ] [[package]] @@ -1644,7 +1644,7 @@ dependencies = [ "itertools 0.13.0", "log", "paste", - "regex-syntax", + "regex-syntax 0.8.5", ] [[package]] @@ -1829,29 +1829,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "env_filter" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea" -dependencies = [ - "log", - "regex", -] - -[[package]] -name = "env_logger" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38b35839ba51819680ba087cd351788c9a3c476841207e0b8cee0b04722343b9" -dependencies = [ - "anstream", - "anstyle", - "env_filter", - "humantime", - "log", -] - [[package]] name = "equivalent" version = "1.0.1" @@ -2720,6 +2697,15 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata 0.1.10", +] + [[package]] name = "matchit" version = "0.7.3" @@ -2832,6 +2818,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + [[package]] name = "num" version = "0.4.2" @@ -3012,6 +3008,12 @@ dependencies = [ "num-traits", ] +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + [[package]] name = "parking" version = "2.2.0" @@ -3117,7 +3119,6 @@ dependencies = [ "crossterm", "datafusion", "derive_more", - "env_logger", "fs_extra", "futures", "futures-util", @@ -3167,6 +3168,7 @@ dependencies = [ "tonic", "tonic-web", "tower-http 0.6.1", + "tracing-subscriber", "ulid", "uptime_lib", "ureq", @@ -3631,8 +3633,17 @@ checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" dependencies = [ "aho-corasick", "memchr", - "regex-automata", - "regex-syntax", + "regex-automata 0.4.8", + "regex-syntax 0.8.5", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", ] [[package]] @@ -3643,7 +3654,7 @@ checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", - "regex-syntax", + "regex-syntax 0.8.5", ] [[package]] @@ -3652,6 +3663,12 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53a49587ad06b26609c52e423de037e7f57f20d53535d66e08c695f347df952a" +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + [[package]] name = "regex-syntax" version = "0.8.5" @@ -4123,6 +4140,15 @@ dependencies = [ "digest", ] +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + [[package]] name = "shlex" version = "1.3.0" @@ -4418,6 +4444,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "thread_local" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" +dependencies = [ + "cfg-if", + "once_cell", +] + [[package]] name = "thrift" version = "0.17.0" @@ -4753,6 +4789,36 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", ] [[package]] @@ -4922,6 +4988,12 @@ dependencies = [ "syn 2.0.79", ] +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + [[package]] name = "vergen" version = "8.3.1" diff --git a/server/Cargo.toml b/server/Cargo.toml index dcf28a3ed..47b5ff801 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -55,7 +55,6 @@ clap = { version = "4.1", default-features = false, features = [ clokwerk = "0.4" crossterm = "0.28.1" derive_more = "0.99.18" -env_logger = "0.11.3" fs_extra = "1.3" futures = "0.3" futures-util = "0.3.28" @@ -90,6 +89,7 @@ tokio = { version = "1.28", default-features = false, features = [ "fs", ] } tokio-stream = { version = "0.1", features = ["fs"] } +tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } ulid = { version = "1.0", features = ["serde"] } uptime_lib = "0.3.0" xxhash-rust = { version = "0.8", features = ["xxh3"] } diff --git a/server/src/main.rs b/server/src/main.rs index fca2ca307..e4163afdd 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -56,7 +56,10 @@ pub const STORAGE_UPLOAD_INTERVAL: u32 = 60; #[actix_web::main] async fn main() -> anyhow::Result<()> { - env_logger::init(); + tracing_subscriber::fmt() + .with_target(false) + .compact() + .init(); // these are empty ptrs so mem footprint should be minimal let server: Arc = match CONFIG.parseable.mode { From 8b3135c7d479360896c0ed2df7c4c99a607ea02e Mon Sep 17 00:00:00 2001 From: Devdutt Shenoi Date: Thu, 21 Nov 2024 12:21:27 +0530 Subject: [PATCH 2/3] fix: load from `RUST_LOG` --- server/src/main.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/src/main.rs b/server/src/main.rs index e4163afdd..90a7c296c 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -48,6 +48,7 @@ use std::sync::Arc; use handlers::http::modal::ParseableServer; use option::{Mode, CONFIG}; +use tracing_subscriber::EnvFilter; use crate::handlers::http::modal::{ ingest_server::IngestServer, query_server::QueryServer, server::Server, @@ -57,6 +58,7 @@ pub const STORAGE_UPLOAD_INTERVAL: u32 = 60; #[actix_web::main] async fn main() -> anyhow::Result<()> { tracing_subscriber::fmt() + .with_env_filter(EnvFilter::from_default_env()) .with_target(false) .compact() .init(); From 3adfb672071b70c28ef9a80107d119b4de7f4a54 Mon Sep 17 00:00:00 2001 From: Devdutt Shenoi Date: Thu, 21 Nov 2024 15:23:51 +0530 Subject: [PATCH 3/3] fix: with target --- server/src/main.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/server/src/main.rs b/server/src/main.rs index 90a7c296c..1a8562160 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -59,7 +59,6 @@ pub const STORAGE_UPLOAD_INTERVAL: u32 = 60; async fn main() -> anyhow::Result<()> { tracing_subscriber::fmt() .with_env_filter(EnvFilter::from_default_env()) - .with_target(false) .compact() .init();