mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-16 07:52:06 +08:00
Refactor logging to use a centralized logging utility across the application (#5277)
- Replaced direct log calls with a new logging macro that includes a logging type for better categorization. - Updated logging in various modules including `merge.rs`, `mod.rs`, `tun.rs`, `clash.rs`, `profile.rs`, `proxy.rs`, `window.rs`, `lightweight.rs`, `guard.rs`, `autostart.rs`, `dirs.rs`, `dns.rs`, `scheme.rs`, `server.rs`, and `window_manager.rs`. - Introduced logging types such as `Core`, `Network`, `ProxyMode`, `Window`, `Lightweight`, `Service`, and `File` to enhance log clarity and filtering.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
use crate::{
|
||||
config::{Config, IVerge},
|
||||
core::handle,
|
||||
logging,
|
||||
utils::logging::Type,
|
||||
};
|
||||
use std::env;
|
||||
use tauri_plugin_clipboard_manager::ClipboardExt;
|
||||
@@ -16,7 +18,11 @@ pub async fn toggle_system_proxy() {
|
||||
&& auto_close_connection
|
||||
&& let Err(err) = handle::Handle::mihomo().await.close_all_connections().await
|
||||
{
|
||||
log::error!(target: "app", "Failed to close all connections: {err}");
|
||||
logging!(
|
||||
error,
|
||||
Type::ProxyMode,
|
||||
"Failed to close all connections: {err}"
|
||||
);
|
||||
}
|
||||
|
||||
let patch_result = super::patch_verge(
|
||||
@@ -30,7 +36,7 @@ pub async fn toggle_system_proxy() {
|
||||
|
||||
match patch_result {
|
||||
Ok(_) => handle::Handle::refresh_verge(),
|
||||
Err(err) => log::error!(target: "app", "{err}"),
|
||||
Err(err) => logging!(error, Type::ProxyMode, "{err}"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +55,7 @@ pub async fn toggle_tun_mode(not_save_file: Option<bool>) {
|
||||
.await
|
||||
{
|
||||
Ok(_) => handle::Handle::refresh_verge(),
|
||||
Err(err) => log::error!(target: "app", "{err}"),
|
||||
Err(err) => logging!(error, Type::ProxyMode, "{err}"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,12 +110,16 @@ pub async fn copy_clash_env() {
|
||||
}
|
||||
"fish" => format!("set -x http_proxy {http_proxy}; set -x https_proxy {http_proxy}"),
|
||||
_ => {
|
||||
log::error!(target: "app", "copy_clash_env: Invalid env type! {env_type}");
|
||||
logging!(
|
||||
error,
|
||||
Type::ProxyMode,
|
||||
"copy_clash_env: Invalid env type! {env_type}"
|
||||
);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
if cliboard.write_text(export_text).is_err() {
|
||||
log::error!(target: "app", "Failed to write to clipboard");
|
||||
logging!(error, Type::ProxyMode, "Failed to write to clipboard");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user