chore: adjust log field

This commit is contained in:
GyDi 2022-03-02 01:13:31 +08:00
parent db6bc10196
commit 220a494692
No known key found for this signature in database
GPG Key ID: 1C95E0D3467B3084
2 changed files with 15 additions and 12 deletions

View File

@ -128,8 +128,8 @@ impl Clash {
tauri::async_runtime::spawn(async move { tauri::async_runtime::spawn(async move {
while let Some(event) = rx.recv().await { while let Some(event) = rx.recv().await {
match event { match event {
CommandEvent::Stdout(line) => log::info!("[stdout]: {}", line), CommandEvent::Stdout(line) => log::info!("[clash]: {}", line),
CommandEvent::Stderr(err) => log::error!("[stderr]: {}", err), CommandEvent::Stderr(err) => log::error!("[clash]: {}", err),
_ => {} _ => {}
} }
} }

View File

@ -1,5 +1,6 @@
use crate::{ use crate::{
core::Clash, core::Clash,
log_if_err,
utils::{config, dirs, sysopt::SysProxyConfig}, utils::{config, dirs, sysopt::SysProxyConfig},
}; };
use anyhow::{bail, Result}; use anyhow::{bail, Result};
@ -58,13 +59,18 @@ impl VergeConfig {
/// Verge App abilities /// Verge App abilities
#[derive(Debug)] #[derive(Debug)]
pub struct Verge { pub struct Verge {
/// manage the verge config
pub config: VergeConfig, pub config: VergeConfig,
pub old_sysproxy: Option<SysProxyConfig>, /// current system proxy setting
pub cur_sysproxy: Option<SysProxyConfig>, pub cur_sysproxy: Option<SysProxyConfig>,
pub auto_launch: Option<AutoLaunch>, /// record the original system proxy
/// recover it when exit
old_sysproxy: Option<SysProxyConfig>,
/// helps to auto launch the app
auto_launch: Option<AutoLaunch>,
/// record whether the guard async is running or not /// record whether the guard async is running or not
guard_state: Arc<Mutex<bool>>, guard_state: Arc<Mutex<bool>>,
@ -282,7 +288,7 @@ impl Verge {
loop { loop {
sleep(Duration::from_secs(wait_secs)).await; sleep(Duration::from_secs(wait_secs)).await;
log::debug!("[Guard]: heartbeat detection"); log::debug!("guard heartbeat detection");
let verge = Verge::new(); let verge = Verge::new();
@ -298,7 +304,7 @@ impl Verge {
break; break;
} }
log::info!("[Guard]: try to guard proxy"); log::info!("try to guard proxy");
let clash = Clash::new(); let clash = Clash::new();
@ -307,12 +313,9 @@ impl Verge {
let bypass = verge.config.system_proxy_bypass.clone(); let bypass = verge.config.system_proxy_bypass.clone();
let sysproxy = SysProxyConfig::new(true, port.clone(), bypass); let sysproxy = SysProxyConfig::new(true, port.clone(), bypass);
if let Err(err) = sysproxy.set_sys() { log_if_err!(sysproxy.set_sys());
log::error!("[Guard]: {err}");
log::error!("[Guard]: fail to set system proxy");
} }
} None => log::error!("fail to parse clash port"),
None => log::error!("[Guard]: fail to parse clash port"),
} }
} }