feat(logging): introduce clash-verge-logging crate for management (#5486)

* feat(logging): introduce clash-verge-logging crate for management

- Added a new crate `clash-verge-logging` with dependencies on `log`, `tokio`, `compact_str`, and `flexi_logger`.
- Implemented logging types and macros for structured logging across the application.
- Replaced existing logging imports with the new `clash_verge_logging` crate in various modules.
- Updated logging functionality to support different logging types and error handling.
- Refactored code to improve logging consistency and maintainability.

* fix(logging): update import paths for clash_verge_logging in linux.rs and dns.rs

* fix(logging): update import statement for clash_verge_logging in windows.rs
This commit is contained in:
Tunglies
2025-11-17 10:42:57 +08:00
committed by GitHub
parent 635f63e9e5
commit 0866b93175
61 changed files with 145 additions and 169 deletions

View File

@@ -3,12 +3,10 @@ use crate::core::sysopt::Sysopt;
use crate::utils::resolve::ui::{self, UiReadyStage};
use crate::{
cmd::StringifyErr as _,
feat, logging,
utils::{
dirs::{self, PathBufExec as _},
logging::Type,
},
feat,
utils::dirs::{self, PathBufExec as _},
};
use clash_verge_logging::{Type, logging};
use smartstring::alias::String;
use std::path::Path;
use tauri::{AppHandle, Manager as _};

View File

@@ -1,4 +1,5 @@
use super::CmdResult;
use crate::feat;
use crate::utils::dirs;
use crate::{
cmd::StringifyErr as _,
@@ -6,7 +7,7 @@ use crate::{
constants,
core::{CoreManager, handle, validate::CoreConfigValidator},
};
use crate::{feat, logging, utils::logging::Type};
use clash_verge_logging::{Type, logging};
use compact_str::CompactString;
use serde_yaml_ng::Mapping;
use smartstring::alias::String;

View File

@@ -1,10 +1,9 @@
use std::sync::Arc;
use clash_verge_logging::{Type, logging};
use regex::Regex;
use reqwest::{Client, cookie::Jar};
use crate::{logging, utils::logging::Type};
use super::UnlockItem;
use super::utils::{country_code_to_emoji, get_local_date_string};

View File

@@ -1,7 +1,7 @@
use regex::Regex;
use reqwest::Client;
use crate::{logging, utils::logging::Type};
use clash_verge_logging::{Type, logging};
use super::UnlockItem;
use super::utils::{country_code_to_emoji, get_local_date_string};

View File

@@ -1,7 +1,7 @@
use regex::Regex;
use reqwest::Client;
use crate::{logging, utils::logging::Type};
use clash_verge_logging::{Type, logging};
use super::UnlockItem;
use super::utils::{country_code_to_emoji, get_local_date_string};

View File

@@ -4,7 +4,7 @@ use reqwest::Client;
use tauri::command;
use tokio::{sync::Mutex, task::JoinSet};
use crate::{logging, utils::logging::Type};
use clash_verge_logging::{Type, logging};
mod bahamut;
mod bilibili;

View File

@@ -1,7 +1,7 @@
use reqwest::Client;
use serde_json::Value;
use crate::{logging, utils::logging::Type};
use clash_verge_logging::{Type, logging};
use super::UnlockItem;
use super::utils::{country_code_to_emoji, get_local_date_string};

View File

@@ -1,7 +1,7 @@
use regex::Regex;
use reqwest::Client;
use crate::{logging, utils::logging::Type};
use clash_verge_logging::{Type, logging};
use super::UnlockItem;
use super::utils::{country_code_to_emoji, get_local_date_string};

View File

@@ -1,7 +1,7 @@
use regex::Regex;
use reqwest::Client;
use crate::{logging, utils::logging::Type};
use clash_verge_logging::{Type, logging};
use super::UnlockItem;
use super::utils::{country_code_to_emoji, get_local_date_string};

View File

@@ -1,6 +1,6 @@
use super::CmdResult;
use crate::cmd::StringifyErr as _;
use crate::{logging, utils::logging::Type};
use clash_verge_logging::{Type, logging};
use gethostname::gethostname;
use network_interface::NetworkInterface;
use serde_yaml_ng::Mapping;

View File

@@ -10,12 +10,13 @@ use crate::{
profiles_append_item_safe,
},
core::{CoreManager, handle, timer::Timer, tray::Tray},
feat, logging,
feat,
module::auto_backup::{AutoBackupManager, AutoBackupTrigger},
process::AsyncHandler,
ret_err,
utils::{dirs, help, logging::Type},
utils::{dirs, help},
};
use clash_verge_logging::{Type, logging};
use scopeguard::defer;
use smartstring::alias::String;
use std::sync::atomic::{AtomicBool, Ordering};

View File

@@ -1,5 +1,5 @@
use super::CmdResult;
use crate::{logging, utils::logging::Type};
use clash_verge_logging::{Type, logging};
// TODO: 前端通过 emit 发送更新事件, tray 监听更新事件
/// 同步托盘和GUI的代理选择状态

View File

@@ -1,8 +1,7 @@
use super::CmdResult;
use crate::{
cmd::StringifyErr as _, config::Config, core::CoreManager, logging_error, utils::logging::Type,
};
use crate::{cmd::StringifyErr as _, config::Config, core::CoreManager};
use anyhow::{Context as _, anyhow};
use clash_verge_logging::{Type, logging_error};
use serde_yaml_ng::Mapping;
use smartstring::alias::String;
use std::collections::HashMap;

View File

@@ -3,10 +3,10 @@ use crate::{
cmd::StringifyErr as _,
config::{Config, PrfItem},
core::{CoreManager, handle, validate::CoreConfigValidator},
logging,
module::auto_backup::{AutoBackupManager, AutoBackupTrigger},
utils::{dirs, logging::Type},
utils::dirs,
};
use clash_verge_logging::{Type, logging};
use smartstring::alias::String;
use tokio::fs;

View File

@@ -3,10 +3,9 @@ use std::sync::Arc;
use super::CmdResult;
use crate::{
core::{CoreManager, handle, manager::RunningMode},
logging,
module::sysinfo::PlatformSpecification,
utils::logging::Type,
};
use clash_verge_logging::{Type, logging};
#[cfg(target_os = "windows")]
use deelevate::{PrivilegeLevel, Token};
use once_cell::sync::Lazy;

View File

@@ -1,9 +1,6 @@
use super::CmdResult;
use crate::{
core::{handle, validate::CoreConfigValidator},
logging,
utils::logging::Type,
};
use crate::core::{handle, validate::CoreConfigValidator};
use clash_verge_logging::{Type, logging};
use smartstring::alias::String;
/// 发送脚本验证通知消息