mirror of
https://github.com/nimbold/Firelink.git
synced 2026-08-08 10:23:29 +00:00
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:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user