mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-20 10:52:08 +08:00
refactor(log): in-place writer lifecycle and span-based core observability (#7889)
* refactor(log): migrate logging to tracing-estuary pipeline Swap flexi_logger + clash-verge-logger wiring for the tracing-estuary crate: buffered file sink with explicit panic/exit drains, live level switching, and tokio-trace/chrome-trace behind crate features. AsyncLogger moves in-house (VecDeque ring); file format and rotation stay unchanged. * fix(log): reset sidecar writer in place and re-pin service-ipc v2.6.7 Rebuilding the sidecar FileLogWriter on config changes leaked flexi's unstoppable flusher thread plus an fd each time; the writer is now flushed and reset in place, matching what the service crate does. get_clash_logs_by_service drops the CompactString conversion layer now that service-ipc v2.6.7 returns plain Vec<String>, and AsyncLogger is renamed LogRing to match. * refactor(log): span-based observability and log noise cleanup Instrument spans carry the structure flat lines never could: the core-start spine (mode, readiness/owner generations, pid, config file), proxy apply and clear routes with guard generations, service IPC sessions with refusal codes and outcomes, profile-switch terminal outcomes, subscription fetch strategies, core upgrades with per-proxy version probes, backup flows, timer tasks, config generation uids, and the startup setup flow; running-mode changes emit one guarded transition event each. ~90 hand-written noise lines are gone or demoted (entry+success pairs, polled getter echoes, phase brackets, window sub-steps, platform install chatter); errors keep their anyhow chain, operation name, and item id, and swallowed retry results surface per attempt.
This commit is contained in:
@@ -33,7 +33,7 @@ mod app_init {
|
||||
/// Initialize singleton monitoring for other instances
|
||||
pub fn init_singleton_check() -> Result<server::SingletonDisposition> {
|
||||
AsyncHandler::block_on(async move {
|
||||
logging!(info, Type::Setup, "开始检查单例实例...");
|
||||
logging!(debug, Type::Setup, "开始检查单例实例...");
|
||||
server::check_singleton().await
|
||||
})
|
||||
}
|
||||
@@ -74,7 +74,7 @@ mod app_init {
|
||||
pub fn setup_deep_links(app: &tauri::App) {
|
||||
#[cfg(any(target_os = "linux", all(debug_assertions, windows)))]
|
||||
{
|
||||
logging!(info, Type::Setup, "注册深层链接...");
|
||||
logging!(debug, Type::Setup, "注册深层链接...");
|
||||
let _ = app.deep_link().register_all();
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ mod app_init {
|
||||
|
||||
/// Setup window state management
|
||||
pub fn setup_window_state(app: &tauri::App) -> Result<(), Box<dyn std::error::Error>> {
|
||||
logging!(info, Type::Setup, "初始化窗口状态管理...");
|
||||
logging!(debug, Type::Setup, "初始化窗口状态管理...");
|
||||
let window_state_plugin = tauri_plugin_window_state::Builder::new()
|
||||
.with_filename(files::WINDOW_STATE)
|
||||
.with_state_flags(tauri_plugin_window_state::StateFlags::default())
|
||||
@@ -280,10 +280,10 @@ pub fn run() -> std::process::ExitCode {
|
||||
.expect("failed to set global app handle");
|
||||
|
||||
if let Err(e) = resolve::init_work_dir_and_logger() {
|
||||
logging!(error, Type::Setup, "Failed to init work dir/logger: {}", e);
|
||||
logging!(error, Type::Setup, "Failed to init work dir/logger: {e:#}");
|
||||
}
|
||||
|
||||
logging!(info, Type::Setup, "开始应用初始化...");
|
||||
logging!(debug, Type::Setup, "开始应用初始化...");
|
||||
if let Err(e) = app_init::setup_autostart(app) {
|
||||
logging!(error, Type::Setup, "Failed to setup autostart: {}", e);
|
||||
}
|
||||
@@ -302,7 +302,6 @@ pub fn run() -> std::process::ExitCode {
|
||||
resolve::resolve_setup_async();
|
||||
resolve::resolve_setup_sync();
|
||||
resolve::init_signal();
|
||||
logging!(info, Type::Setup, "初始化已启动");
|
||||
})) {
|
||||
log_setup_panic("window-core", panic);
|
||||
}
|
||||
@@ -470,6 +469,7 @@ pub fn run() -> std::process::ExitCode {
|
||||
);
|
||||
}
|
||||
logging!(info, Type::System, "Application exited");
|
||||
crate::core::logger::Logger::global().flush_logs();
|
||||
}),
|
||||
#[allow(unused_variables)]
|
||||
tauri::RunEvent::ExitRequested { api, code, .. } => {
|
||||
|
||||
Reference in New Issue
Block a user