From e0a79be5ddf248e493dcb57b6e5474cf01afb06b Mon Sep 17 00:00:00 2001 From: 1111mp Date: Wed, 6 Nov 2024 17:32:59 +0800 Subject: [PATCH] fix: filter the logs inside tauri to reduce the amount of logs Signed-off-by: 1111mp --- src-tauri/capabilities/default.json | 3 ++- src-tauri/src/main.rs | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json index 79aa1ba..943eef7 100644 --- a/src-tauri/capabilities/default.json +++ b/src-tauri/capabilities/default.json @@ -56,6 +56,7 @@ "shell:allow-stdin-write", "dialog:default", "updater:default", - "window-state:default" + "window-state:default", + "log:default" ] } \ No newline at end of file diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 493f391..21252ca 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -75,7 +75,7 @@ fn main() -> tauri::Result<()> { #[cfg(not(debug_assertions))] { - use tauri_plugin_log::{Builder, Target, TargetKind}; + use tauri_plugin_log::{Builder, Target, TargetKind, TimezoneStrategy}; let log_plugin = Builder::default() .rotation_strategy(tauri_plugin_log::RotationStrategy::KeepAll) @@ -84,6 +84,12 @@ fn main() -> tauri::Result<()> { Target::new(TargetKind::LogDir { file_name: None }), // Target::new(TargetKind::Webview), ]) + .timezone_strategy(TimezoneStrategy::UseLocal) + .level(log::LevelFilter::Info) + .filter(|metadata| { + let target = metadata.target(); + target == "app" || target == "migrate" + }) .build(); builder = builder.plugin(log_plugin);