refactor: Add logger

This commit is contained in:
Kevin Yue
2023-05-23 14:30:20 +08:00
parent cbd8b0f144
commit 462428f99a
15 changed files with 430 additions and 91 deletions

View File

@@ -17,7 +17,8 @@
"@tauri-apps/api": "^1.2.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-spinners": "^0.13.8"
"react-spinners": "^0.13.8",
"tauri-plugin-log-api": "github:tauri-apps/tauri-plugin-log"
},
"devDependencies": {
"@tauri-apps/cli": "^1.2.3",

11
gpgui/pnpm-lock.yaml generated
View File

@@ -28,6 +28,9 @@ dependencies:
react-spinners:
specifier: ^0.13.8
version: 0.13.8(react-dom@18.2.0)(react@18.2.0)
tauri-plugin-log-api:
specifier: github:tauri-apps/tauri-plugin-log
version: github.com/tauri-apps/tauri-plugin-log/5e14c2cad7335a4284a6caad81d8cf37dd675a27
devDependencies:
'@tauri-apps/cli':
@@ -1389,3 +1392,11 @@ packages:
resolution: {integrity: sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==}
engines: {node: '>= 6'}
dev: false
github.com/tauri-apps/tauri-plugin-log/5e14c2cad7335a4284a6caad81d8cf37dd675a27:
resolution: {tarball: https://codeload.github.com/tauri-apps/tauri-plugin-log/tar.gz/5e14c2cad7335a4284a6caad81d8cf37dd675a27}
name: tauri-plugin-log-api
version: 0.0.0
dependencies:
'@tauri-apps/api': 1.2.0
dev: false

View File

@@ -15,15 +15,18 @@ rust-version = "1.59"
tauri-build = { version = "1.2.1", features = [] }
[dependencies]
tauri = { version = "1.2.4", 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"] }
tauri = { version = "1.2.4", features = ["http-all"] }
log = "0.4"
env_logger = "0.10"
common = { path = "../../common" }
[features]
# by default Tauri runs in production mode
# when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL
default = [ "custom-protocol" ]
default = ["custom-protocol"]
# this feature is used for production builds where `devPath` points to the filesystem
# DO NOT remove this
custom-protocol = [ "tauri/custom-protocol" ]
custom-protocol = ["tauri/custom-protocol"]

View File

@@ -4,6 +4,7 @@
)]
use common::{Client, ServerApiError, VpnStatus};
use env_logger::Env;
use serde::Serialize;
use std::sync::Arc;
use tauri::{Manager, State};
@@ -53,6 +54,8 @@ 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();
tauri::Builder::default()
.setup(setup)
.invoke_handler(tauri::generate_handler![