[desktop] Move logging to user dir on windows.

This commit is contained in:
Vladimir Stoilov
2024-08-30 14:49:35 +03:00
parent 30eb77d213
commit 2ea21b5fb8
4 changed files with 2053 additions and 1959 deletions

View File

@@ -200,6 +200,7 @@ fn main() {
cli.with_notifications = *value;
}
#[cfg(target_os = "linux")]
let log_target = if let Some(data_dir) = cli.data {
tauri_plugin_log::Target::new(tauri_plugin_log::TargetKind::Folder {
path: Path::new(&format!("{}/logs/app2", data_dir)).into(),
@@ -209,6 +210,14 @@ fn main() {
tauri_plugin_log::Target::new(tauri_plugin_log::TargetKind::Stdout)
};
// TODO(vladimir): Permission for logs/app2 folder are not guaranteed. Use the default location for now.
#[cfg(target_os = "windows")]
let log_target = if let Some(data_dir) = cli.data {
tauri_plugin_log::Target::new(tauri_plugin_log::TargetKind::LogDir { file_name: None })
} else {
tauri_plugin_log::Target::new(tauri_plugin_log::TargetKind::Stdout)
};
let mut log_level = LOG_LEVEL;
match cli.log.as_ref() {
"off" => log_level = LevelFilter::Off,