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
+40
View File
@@ -0,0 +1,40 @@
import { info as tauriInfo, warn as tauriWarn, error as tauriError, debug as tauriDebug, trace as tauriTrace, attachLogger as tauriAttachLogger } from '@tauri-apps/plugin-log';
import { invoke } from '@tauri-apps/api/core';
// Default to true to match backend default
let isPaused = true;
let initPromise: Promise<void> | null = null;
export const initLogger = () => {
if (!initPromise) {
initPromise = invoke<boolean>('is_log_paused')
.then(paused => { isPaused = paused; })
.catch(e => console.error("Failed to init logger state", e));
}
return initPromise;
};
export const setLogPaused = async (pause: boolean) => {
isPaused = pause;
await invoke('toggle_log_pause', { pause }).catch(console.error);
};
export const getLogPaused = () => isPaused;
export const info = async (message: string) => {
if (!isPaused) return tauriInfo(message);
};
export const warn = async (message: string) => {
if (!isPaused) return tauriWarn(message);
};
export const error = async (message: string) => {
if (!isPaused) return tauriError(message);
};
export const debug = async (message: string) => {
if (!isPaused) return tauriDebug(message);
};
export const trace = async (message: string) => {
if (!isPaused) return tauriTrace(message);
};
export const attachLogger = tauriAttachLogger;