feat(logging): default to paused state and prevent performance hit via frontend wrapper

- Default LOG_PAUSED to true in backend.
- Combine tauri_plugin_log filters to drop backend logs when paused.
- Create frontend logger wrapper to intercept and drop logs before IPC when paused.
- Sync LogsView state directly with logger wrapper and handle initialization races.
This commit is contained in:
NimBold
2026-06-23 04:33:24 +03:30
parent ddd4662898
commit eae3cf6180
8 changed files with 58 additions and 13 deletions
+4 -2
View File
@@ -3730,7 +3730,7 @@ mod tests {
}
}
static LOG_PAUSED: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false);
static LOG_PAUSED: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(true);
#[tauri::command]
fn toggle_log_pause(pause: bool) {
@@ -4085,13 +4085,15 @@ pub fn run() {
})
.plugin(
tauri_plugin_log::Builder::new()
.filter(|_meta| !LOG_PAUSED.load(std::sync::atomic::Ordering::Relaxed))
.targets([
tauri_plugin_log::Target::new(tauri_plugin_log::TargetKind::Stdout),
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| {
if LOG_PAUSED.load(std::sync::atomic::Ordering::Relaxed) {
return false;
}
let target = metadata.target();
!target.starts_with("webview::")
&& !target.starts_with("hyper")