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 {
while let Some(event) = rx.recv().await {
match event {
CommandEvent::Stdout(line) => log::info!("[stdout]: {}", line),
CommandEvent::Stderr(err) => log::error!("[stderr]: {}", err),
CommandEvent::Stdout(line) => log::info!("[clash]: {}", line),
CommandEvent::Stderr(err) => log::error!("[clash]: {}", err),
_ => {}
}
}

View File

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