refactor: 使用 tracing 输出日志 (#1856)

* change all println to tracing
This commit is contained in:
Luna Yao
2026-03-04 02:52:23 +01:00
committed by GitHub
parent 1d25240d8c
commit 5f31583a84
18 changed files with 488 additions and 384 deletions
+6 -8
View File
@@ -2,7 +2,7 @@ use std::sync::Arc;
use crate::{
common::{
config::TomlConfigLoader, global_ctx::GlobalCtx, scoped_task::ScopedTask,
config::TomlConfigLoader, global_ctx::GlobalCtx, log, scoped_task::ScopedTask,
set_default_machine_id, stun::MockStunInfoCollector,
},
connector::create_connector_by_url,
@@ -87,18 +87,16 @@ impl WebClient {
loop {
let conn = match connector.connect().await {
Ok(conn) => conn,
Err(e) => {
println!(
"Failed to connect to the server ({}), retrying in 5 seconds...",
e
);
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
Err(error) => {
let wait = 1;
log::warn!(%error, "Failed to connect to the server, retrying in {} seconds...", wait);
tokio::time::sleep(std::time::Duration::from_secs(wait)).await;
continue;
}
};
connected.store(true, Ordering::Release);
println!("Successfully connected to {:?}", conn.info());
log::info!("Successfully connected to {:?}", conn.info());
let mut session = session::Session::new(conn, controller.clone());
session.wait().await;