diff --git a/Cargo.lock b/Cargo.lock index 3fbda69e..730efa25 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -245,6 +245,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + [[package]] name = "anyhow" version = "1.0.38" @@ -298,17 +307,6 @@ dependencies = [ "num-traits 0.2.14", ] -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi", - "libc", - "winapi", -] - [[package]] name = "autocfg" version = "1.0.1" @@ -609,7 +607,6 @@ dependencies = [ "config", "crossbeam-channel", "dotenv", - "env_logger", "futures", "futures-channel", "futures-core", @@ -635,6 +632,9 @@ dependencies = [ "tokio", "tonic", "tonic-build", + "tracing", + "tracing-appender", + "tracing-subscriber", "ttl_cache", ] @@ -665,19 +665,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "env_logger" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17392a012ea30ef05a610aa97dfb49496e71c9f676b27879922ea5bdf60d9d3f" -dependencies = [ - "atty", - "humantime", - "log", - "regex", - "termcolor", -] - [[package]] name = "fallible-iterator" version = "0.2.0" @@ -1138,6 +1125,15 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" +[[package]] +name = "matchers" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" +dependencies = [ + "regex-automata", +] + [[package]] name = "matches" version = "0.1.8" @@ -1729,6 +1725,15 @@ dependencies = [ "thread_local", ] +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax", +] + [[package]] name = "regex-syntax" version = "0.6.22" @@ -1952,6 +1957,15 @@ dependencies = [ "opaque-debug", ] +[[package]] +name = "sharded-slab" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79c719719ee05df97490f80a45acfc99e5a30ce98a1e4fb67aee422745ae14e3" +dependencies = [ + "lazy_static", +] + [[package]] name = "signal-hook-registry" version = "1.3.0" @@ -2213,15 +2227,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "termcolor" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" -dependencies = [ - "winapi-util", -] - [[package]] name = "thiserror" version = "1.0.24" @@ -2511,6 +2516,17 @@ dependencies = [ "tracing-core", ] +[[package]] +name = "tracing-appender" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9965507e507f12c8901432a33e31131222abac31edd90cabbcf85cf544b7127a" +dependencies = [ + "chrono", + "crossbeam-channel", + "tracing-subscriber", +] + [[package]] name = "tracing-attributes" version = "0.1.13" @@ -2541,6 +2557,49 @@ dependencies = [ "tracing", ] +[[package]] +name = "tracing-log" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6923477a48e41c1951f1999ef8bb5a3023eb723ceadafe78ffb65dc366761e3" +dependencies = [ + "lazy_static", + "log", + "tracing-core", +] + +[[package]] +name = "tracing-serde" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb65ea441fbb84f9f6748fd496cf7f63ec9af5bca94dd86456978d055e8eb28b" +dependencies = [ + "serde 1.0.124", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa5553bf0883ba7c9cbe493b085c29926bd41b66afc31ff72cf17ff4fb60dcd5" +dependencies = [ + "ansi_term", + "chrono", + "lazy_static", + "matchers", + "regex", + "serde 1.0.124", + "serde_json", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", + "tracing-serde", +] + [[package]] name = "try-lock" version = "0.2.3" @@ -2769,15 +2828,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -[[package]] -name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi", -] - [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" diff --git a/Cargo.toml b/Cargo.toml index eac2ec09..aec9aad4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,6 @@ chrono = { version = "0.4.19", features = [ "serde" ] } config_rs = { package = "config", version = "0.10.1" } crossbeam-channel = "0.5.0" dotenv = "0.15.0" -env_logger = "0.8.3" futures = "0.3.13" futures-channel = "0.3.13" futures-core = { version = "0.3.13", default-features = false } @@ -38,6 +37,9 @@ thiserror = "1.0.24" thread-id = "3.3.0" tokio = { version = "1.6.0", features = [ "full" ] } tonic = "0.4.0" +tracing = "0.1" +tracing-appender = "0.1" +tracing-subscriber = "0.2" ttl_cache = "0.5.1" [build-dependencies] diff --git a/src/bin/matchengine.rs b/src/bin/matchengine.rs index 296b11d4..bda4489c 100644 --- a/src/bin/matchengine.rs +++ b/src/bin/matchengine.rs @@ -16,7 +16,13 @@ use sqlx::Connection; fn main() { dotenv::dotenv().ok(); - env_logger::init(); + + let (non_blocking, _guard) = tracing_appender::non_blocking(std::io::stdout()); + tracing_subscriber::fmt() + .with_env_filter(tracing_subscriber::EnvFilter::from_default_env()) + .with_writer(non_blocking) + .init(); + let rt: tokio::runtime::Runtime = tokio::runtime::Builder::new_multi_thread() .enable_all() .build() diff --git a/src/bin/persistor.rs b/src/bin/persistor.rs index 1188ff45..33295bff 100644 --- a/src/bin/persistor.rs +++ b/src/bin/persistor.rs @@ -15,7 +15,12 @@ use message::persist::{self, TopicConfig, MIGRATOR}; fn main() { dotenv::dotenv().ok(); - env_logger::init(); + + let (non_blocking, _guard) = tracing_appender::non_blocking(std::io::stdout()); + tracing_subscriber::fmt() + .with_env_filter(tracing_subscriber::EnvFilter::from_default_env()) + .with_writer(non_blocking) + .init(); let mut conf = config_rs::Config::new(); let config_file = dotenv::var("CONFIG_FILE").unwrap(); diff --git a/src/bin/restapi.rs b/src/bin/restapi.rs index 9b3d2b82..9f1d2c6b 100644 --- a/src/bin/restapi.rs +++ b/src/bin/restapi.rs @@ -27,7 +27,13 @@ async fn ping(_req: HttpRequest, _data: web::Data) -> impl Responder { #[actix_web::main] async fn main() -> std::io::Result<()> { dotenv::dotenv().ok(); - env_logger::init(); + + let (non_blocking, _guard) = tracing_appender::non_blocking(std::io::stdout()); + tracing_subscriber::fmt() + .with_env_filter(tracing_subscriber::EnvFilter::from_default_env()) + .with_writer(non_blocking) + .init(); + let mut conf = config_rs::Config::new(); let config_file = dotenv::var("CONFIG_FILE").unwrap(); conf.merge(config_rs::File::with_name(&config_file)).unwrap(); diff --git a/src/bin/test_unifymessenger.rs b/src/bin/test_unifymessenger.rs index 4414a8fc..353b5860 100644 --- a/src/bin/test_unifymessenger.rs +++ b/src/bin/test_unifymessenger.rs @@ -37,7 +37,12 @@ impl SimpleMessageHandler for &MessageWriter { fn main() { dotenv::dotenv().ok(); - env_logger::init(); + + let (non_blocking, _guard) = tracing_appender::non_blocking(std::io::stdout()); + tracing_subscriber::fmt() + .with_env_filter(tracing_subscriber::EnvFilter::from_default_env()) + .with_writer(non_blocking) + .init(); let mut conf = config_rs::Config::new(); let config_file = dotenv::var("CONFIG_FILE").unwrap();