Skip to content

Commit

Permalink
refactor: make config's loglevel only affect tuic
Browse files Browse the repository at this point in the history
  • Loading branch information
Itsusinn committed Nov 4, 2024
1 parent 4967d7c commit 3a0e183
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
9 changes: 7 additions & 2 deletions tuic-server/src/connection/udp_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ impl UdpSession {
tokio::select! {
recv = session_listening.recv() => next = recv,
// Avoid client didn't send `UDP-DROP` properly
_ = timeout.tick() => break,
_ = timeout.tick() => {
session_listening.close().await;
break
},
// `UDP-DROP`
_ = &mut rx => break
}
Expand Down Expand Up @@ -166,7 +169,9 @@ impl UdpSession {
}

pub async fn close(&self) {
let _ = self.close.write().await.take().unwrap().send(());
if let Some(v) = self.close.write().await.take() {
_ = v.send(());
}
}
}

Expand Down
9 changes: 8 additions & 1 deletion tuic-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::{env, process};
use chrono::{Local, Offset, TimeZone};
use config::{Config, parse_config};
use lateinit::LateInit;
use tracing::level_filters::LevelFilter;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};

use crate::{old_config::ConfigError, server::Server};
Expand Down Expand Up @@ -37,7 +38,13 @@ async fn main() -> eyre::Result<()> {
unsafe {
CONFIG.init(cfg);
}
let filter = tracing_subscriber::filter::Targets::new().with_default(CONFIG.log_level);
let filter = tracing_subscriber::filter::Targets::new()
.with_targets(vec![
("tuic", CONFIG.log_level),
("tuic_quinn", CONFIG.log_level),
("tuic_server", CONFIG.log_level),
])
.with_default(LevelFilter::INFO);
let registry = tracing_subscriber::registry();
registry
.with(filter)
Expand Down

0 comments on commit 3a0e183

Please sign in to comment.