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:
Tunglies
2025-11-01 20:47:01 +08:00
committed by GitHub
parent 50567d9b97
commit fb260fb33d
28 changed files with 473 additions and 210 deletions

View File

@@ -1,6 +1,7 @@
use crate::config::Config;
use crate::utils::dirs::{ipc_path, path_to_str};
use crate::utils::{dirs, help};
use crate::{logging, utils::logging::Type};
use anyhow::Result;
use serde::{Deserialize, Serialize};
use serde_yaml_ng::{Mapping, Value};
@@ -40,7 +41,7 @@ impl IClashTemp {
Self(Self::guard(map))
}
Err(err) => {
log::error!(target: "app", "{err}");
logging!(error, Type::Config, "{err}");
template
}
}
@@ -330,7 +331,7 @@ impl IClashTemp {
.ok()
.and_then(|path| path_to_str(&path).ok().map(|s| s.into()))
.unwrap_or_else(|| {
log::error!(target: "app", "Failed to get IPC path");
logging!(error, Type::Config, "Failed to get IPC path");
crate::constants::network::DEFAULT_EXTERNAL_CONTROLLER.into()
})
}