mirror of
https://github.com/nimbold/Firelink.git
synced 2026-08-07 01:44:01 +00:00
feat: enhance log system with true deletion, noise filtering, and error boundaries
- Implemented `clear_logs` Tauri command to physically wipe local log files. - Added a global `ErrorBoundary` to cleanly intercept React render loops (e.g. Error #185) and provide readable stack traces. - Hardened `tauri_plugin_log` to filter out `webview`, `hyper`, `reqwest`, `rustls` log noise. - Replaced the default browser right-click menu in LogsView with a custom native React menu for copying text securely.
This commit is contained in:
+18
-1
@@ -3183,6 +3183,14 @@ async fn read_logs(app_handle: tauri::AppHandle, limit: usize) -> Result<Vec<Str
|
||||
Ok(lines)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn clear_logs(app_handle: tauri::AppHandle) -> Result<(), String> {
|
||||
for file in log_files(&app_handle).await? {
|
||||
let _ = tokio::fs::write(&file, "").await;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn export_logs(
|
||||
app_handle: tauri::AppHandle,
|
||||
@@ -4081,6 +4089,15 @@ pub fn run() {
|
||||
tauri_plugin_log::Target::new(tauri_plugin_log::TargetKind::LogDir { file_name: None }),
|
||||
])
|
||||
.level(if cfg!(debug_assertions) { log::LevelFilter::Debug } else { log::LevelFilter::Info })
|
||||
.filter(|metadata| {
|
||||
let target = metadata.target();
|
||||
!target.starts_with("webview::")
|
||||
&& !target.starts_with("hyper")
|
||||
&& !target.starts_with("reqwest")
|
||||
&& !target.starts_with("rustls")
|
||||
&& !target.starts_with("h2")
|
||||
&& !target.starts_with("tower")
|
||||
})
|
||||
.max_file_size(10_000_000)
|
||||
.rotation_strategy(tauri_plugin_log::RotationStrategy::KeepSome(3))
|
||||
.timezone_strategy(tauri_plugin_log::TimezoneStrategy::UseLocal)
|
||||
@@ -4116,7 +4133,7 @@ pub fn run() {
|
||||
parity::create_category_directories,
|
||||
db_save_settings, db_load_settings, db_get_all_downloads, db_replace_downloads,
|
||||
db_get_all_queues, db_replace_queues,
|
||||
read_logs, export_logs, toggle_log_pause, is_log_paused
|
||||
read_logs, export_logs, toggle_log_pause, is_log_paused, clear_logs
|
||||
])
|
||||
.build(tauri::generate_context!())
|
||||
.expect("error while building tauri application")
|
||||
|
||||
Reference in New Issue
Block a user