diff --git a/editoast/Cargo.lock b/editoast/Cargo.lock index 8aaed63338d..c6bcb780538 100644 --- a/editoast/Cargo.lock +++ b/editoast/Cargo.lock @@ -1171,7 +1171,6 @@ dependencies = [ "diesel_json", "editoast_derive", "enum-map", - "env_logger", "futures 0.3.30", "futures-util", "geos", @@ -1208,6 +1207,7 @@ dependencies = [ "thiserror", "tokio", "tokio-postgres", + "tracing-subscriber", "url", "utoipa", "uuid", @@ -1260,19 +1260,6 @@ dependencies = [ "syn 2.0.48", ] -[[package]] -name = "env_logger" -version = "0.10.1" -source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "95b3f3e67048839cb0d0781f445682a35113da7121f7c949db0e2be96a4fbece" -dependencies = [ - "humantime", - "is-terminal", - "log", - "regex", - "termcolor", -] - [[package]] name = "equivalent" version = "1.0.1" @@ -1805,12 +1792,6 @@ version = "1.0.3" source = "registry+/~https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" -[[package]] -name = "humantime" -version = "2.1.0" -source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - [[package]] name = "hyper" version = "0.14.28" @@ -1967,17 +1948,6 @@ version = "2.9.0" source = "registry+/~https://github.com/rust-lang/crates.io-index" checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" -[[package]] -name = "is-terminal" -version = "0.4.10" -source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "0bad00257d07be169d870ab665980b06cdb366d792ad690bf2e76876dc503455" -dependencies = [ - "hermit-abi", - "rustix 0.38.30", - "windows-sys 0.52.0", -] - [[package]] name = "itertools" version = "0.12.0" @@ -2125,6 +2095,15 @@ version = "0.1.0" source = "registry+/~https://github.com/rust-lang/crates.io-index" checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" +[[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 = "maybe-uninit" version = "2.0.0" @@ -2216,6 +2195,16 @@ dependencies = [ "tempfile", ] +[[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.1" @@ -2414,6 +2403,12 @@ dependencies = [ "utoipa", ] +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+/~https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + [[package]] name = "owning_ref" version = "0.3.3" @@ -2963,8 +2958,17 @@ checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" dependencies = [ "aho-corasick", "memchr", - "regex-automata", - "regex-syntax", + "regex-automata 0.4.3", + "regex-syntax 0.8.2", +] + +[[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]] @@ -2975,9 +2979,15 @@ checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" dependencies = [ "aho-corasick", "memchr", - "regex-syntax", + "regex-syntax 0.8.2", ] +[[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.2" @@ -3420,6 +3430,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 = "signal-hook-registry" version = "1.4.1" @@ -3616,15 +3635,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "termcolor" -version = "1.4.1" -source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" -dependencies = [ - "winapi-util", -] - [[package]] name = "thiserror" version = "1.0.56" @@ -3645,6 +3655,16 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "thread_local" +version = "1.1.7" +source = "registry+/~https://github.com/rust-lang/crates.io-index" +checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" +dependencies = [ + "cfg-if", + "once_cell", +] + [[package]] name = "tiff" version = "0.9.1" @@ -3818,13 +3838,33 @@ dependencies = [ "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 1.12.0", + "thread_local", + "tracing", "tracing-core", + "tracing-log", ] [[package]] @@ -4161,15 +4201,6 @@ version = "0.4.0" source = "registry+/~https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -[[package]] -name = "winapi-util" -version = "0.1.6" -source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" -dependencies = [ - "winapi", -] - [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" diff --git a/editoast/Cargo.toml b/editoast/Cargo.toml index 5d0148ce1f8..c73834ee158 100644 --- a/editoast/Cargo.toml +++ b/editoast/Cargo.toml @@ -45,7 +45,7 @@ actix-files = "0.6.5" actix-web = "4.4.1" actix-http = "3.5.1" actix-cors = "0.7.0" -env_logger = "0.10.1" +tracing-subscriber = { version = "0.3.18", features = [ "env-filter" ] } log = "0.4.20" redis = { version = "0.24.0", features = [ "tokio-comp", diff --git a/editoast/src/main.rs b/editoast/src/main.rs index 52e334d4ef8..3e3ba5c8979 100644 --- a/editoast/src/main.rs +++ b/editoast/src/main.rs @@ -70,10 +70,20 @@ use views::search::{SearchConfig, SearchConfigFinder, SearchConfigStore}; type DbPool = Pool; +fn init_tracing() { + tracing_subscriber::registry() + .with( + tracing_subscriber::EnvFilter::builder() + // Set the default log level to 'info' + .with_default_directive(tracing_subscriber::filter::LevelFilter::INFO.into()) + .from_env_lossy(), + ) + .with(tracing_subscriber::fmt::layer().pretty()) +} + #[actix_web::main] async fn main() { - // Set the default log level to 'info' - env_logger::init_from_env(env_logger::Env::new().default_filter_or("info")); + init_tracing(); match run().await { Ok(_) => (),