diff --git a/rpxy-bin/Cargo.toml b/rpxy-bin/Cargo.toml index a426012..4242741 100644 --- a/rpxy-bin/Cargo.toml +++ b/rpxy-bin/Cargo.toml @@ -26,9 +26,9 @@ rpxy-lib = { path = "../rpxy-lib/", default-features = false, features = [ "sticky-cookie", ] } -anyhow = "1.0.82" +anyhow = "1.0.86" rustc-hash = "1.1.0" -serde = { version = "1.0.199", default-features = false, features = ["derive"] } +serde = { version = "1.0.202", default-features = false, features = ["derive"] } derive_builder = "0.20.0" tokio = { version = "1.37.0", default-features = false, features = [ "net", @@ -43,7 +43,7 @@ mimalloc = { version = "*", default-features = false } # config clap = { version = "4.5.4", features = ["std", "cargo", "wrap_help"] } -toml = { version = "0.8.12", default-features = false, features = ["parse"] } +toml = { version = "0.8.13", default-features = false, features = ["parse"] } hot_reload = "0.1.5" # logging diff --git a/rpxy-bin/src/log.rs b/rpxy-bin/src/log.rs index f910e94..7076fac 100644 --- a/rpxy-bin/src/log.rs +++ b/rpxy-bin/src/log.rs @@ -1,28 +1,30 @@ +use std::str::FromStr; +use tracing_subscriber::{fmt, prelude::*}; + #[allow(unused)] pub use tracing::{debug, error, info, warn}; +/// Initialize the logger with the RUST_LOG environment variable. pub fn init_logger() { - use tracing_subscriber::{fmt, prelude::*, EnvFilter}; + let level_string = std::env::var("RUST_LOG").unwrap_or_else(|_| "info".to_string()); + let level = tracing::Level::from_str(level_string.as_str()).unwrap_or(tracing::Level::INFO); - let format_layer = fmt::layer() - .with_line_number(false) + // This limits the logger to emits only this crate with any level, for included crates it will emit only INFO or above level. + let stdio_layer = fmt::layer() + .with_line_number(true) .with_thread_ids(false) - .with_target(false) .with_thread_names(true) .with_target(true) .with_level(true) - .compact(); + .compact() + .with_filter(tracing_subscriber::filter::filter_fn(move |metadata| { + (metadata + .target() + .starts_with(env!("CARGO_PKG_NAME").replace('-', "_").as_str()) + && metadata.level() <= &level) + || metadata.level() <= &tracing::Level::INFO.min(level) + })); - // This limits the logger to emits only proxy crate - let pkg_name = env!("CARGO_PKG_NAME").replace('-', "_"); - let level_string = std::env::var(EnvFilter::DEFAULT_ENV).unwrap_or_else(|_| "info".to_string()); - let filter_layer = EnvFilter::new(format!("{}={}", pkg_name, level_string)); - // let filter_layer = EnvFilter::try_from_default_env() - // .unwrap_or_else(|_| EnvFilter::new("info")) - // .add_directive(format!("{}=trace", pkg_name).parse().unwrap()); - - tracing_subscriber::registry() - .with(format_layer) - .with(filter_layer) - .init(); + let reg = tracing_subscriber::registry().with(stdio_layer); + reg.init(); } diff --git a/rpxy-lib/Cargo.toml b/rpxy-lib/Cargo.toml index 480a6b5..699680a 100644 --- a/rpxy-lib/Cargo.toml +++ b/rpxy-lib/Cargo.toml @@ -46,8 +46,8 @@ pin-project-lite = "0.2.14" async-trait = "0.1.80" # Error handling -anyhow = "1.0.82" -thiserror = "1.0.59" +anyhow = "1.0.86" +thiserror = "1.0.61" # http for both server and client http = "1.1.0" @@ -103,7 +103,7 @@ chrono = { version = "0.4.38", default-features = false, features = [ "alloc", "clock", ], optional = true } -base64 = { version = "0.22.0", optional = true } +base64 = { version = "0.22.1", optional = true } [dev-dependencies] diff --git a/submodules/h3 b/submodules/h3 index c11410c..b44edeb 160000 --- a/submodules/h3 +++ b/submodules/h3 @@ -1 +1 @@ -Subproject commit c11410c76e738a62e62e7766b82f814547621f6f +Subproject commit b44edeb60d234d49c45828395108f7519a048d4b