refactor: add the log plugin

This commit is contained in:
Kevin Yue
2023-05-23 16:38:29 +08:00
parent 462428f99a
commit 8de183a53d
6 changed files with 304 additions and 149 deletions

View File

@@ -14,7 +14,7 @@
"@mui/icons-material": "^5.11.11",
"@mui/lab": "5.0.0-alpha.125",
"@mui/material": "^5.11.11",
"@tauri-apps/api": "^1.2.0",
"@tauri-apps/api": "^1.3.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-spinners": "^0.13.8",

10
gpgui/pnpm-lock.yaml generated
View File

@@ -17,8 +17,8 @@ dependencies:
specifier: ^5.11.11
version: 5.11.11(@emotion/react@11.10.6)(@emotion/styled@11.10.6)(@types/react@18.0.28)(react-dom@18.2.0)(react@18.2.0)
'@tauri-apps/api':
specifier: ^1.2.0
version: 1.2.0
specifier: ^1.3.0
version: 1.3.0
react:
specifier: ^18.2.0
version: 18.2.0
@@ -848,8 +848,8 @@ packages:
'@swc/core-win32-x64-msvc': 1.3.36
dev: true
/@tauri-apps/api@1.2.0:
resolution: {integrity: sha512-lsI54KI6HGf7VImuf/T9pnoejfgkNoXveP14pVV7XarrQ46rOejIVJLFqHI9sRReJMGdh2YuCoI3cc/yCWCsrw==}
/@tauri-apps/api@1.3.0:
resolution: {integrity: sha512-AH+3FonkKZNtfRtGrObY38PrzEj4d+1emCbwNGu0V2ENbXjlLHMZQlUh+Bhu/CRmjaIwZMGJ3yFvWaZZgTHoog==}
engines: {node: '>= 14.6.0', npm: '>= 6.6.0', yarn: '>= 1.19.1'}
dev: false
@@ -1398,5 +1398,5 @@ packages:
name: tauri-plugin-log-api
version: 0.0.0
dependencies:
'@tauri-apps/api': 1.2.0
'@tauri-apps/api': 1.3.0
dev: false

View File

@@ -12,10 +12,10 @@ rust-version = "1.59"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[build-dependencies]
tauri-build = { version = "1.2.1", features = [] }
tauri-build = { version = "1.3", features = [] }
[dependencies]
tauri = { version = "1.2.4", features = ["http-all"] }
tauri = { version = "1.3", features = ["http-all"] }
tauri-plugin-log = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }

View File

@@ -8,6 +8,7 @@ use env_logger::Env;
use serde::Serialize;
use std::sync::Arc;
use tauri::{Manager, State};
use tauri_plugin_log::LogTarget;
#[tauri::command]
async fn vpn_status<'a>(client: State<'a, Arc<Client>>) -> Result<VpnStatus, ServerApiError> {
@@ -54,9 +55,17 @@ fn setup(app: &mut tauri::App) -> Result<(), Box<dyn std::error::Error>> {
}
fn main() {
env_logger::Builder::from_env(Env::default().default_filter_or("info")).init();
// env_logger::Builder::from_env(Env::default().default_filter_or("info")).init();
tauri::Builder::default()
.plugin(
tauri_plugin_log::Builder::default()
.targets([
LogTarget::LogDir,
LogTarget::Stdout, /*LogTarget::Webview*/
])
.build(),
)
.setup(setup)
.invoke_handler(tauri::generate_handler![
vpn_status,