mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 17:15:38 +08:00
Refactor logging statements to use the new formatting syntax for improved readability and consistency across the codebase. This includes updating error, warning, and info logs in various modules such as system commands, configuration, core functionalities, and utilities. Additionally, minor adjustments were made to string formatting in backup and proxy features to enhance clarity.
This commit is contained in:
@@ -172,7 +172,7 @@ impl CoreManager {
|
||||
|
||||
// 检查文件是否存在
|
||||
if !std::path::Path::new(config_path).exists() {
|
||||
let error_msg = format!("File not found: {}", config_path);
|
||||
let error_msg = format!("File not found: {config_path}");
|
||||
//handle::Handle::notice_message("config_validate::file_not_found", &error_msg);
|
||||
return Ok((false, error_msg));
|
||||
}
|
||||
@@ -284,7 +284,7 @@ impl CoreManager {
|
||||
} else if !stderr.is_empty() {
|
||||
stderr.to_string()
|
||||
} else if let Some(code) = output.status.code() {
|
||||
format!("验证进程异常退出,退出码: {}", code)
|
||||
format!("验证进程异常退出,退出码: {code}")
|
||||
} else {
|
||||
"验证进程被终止".to_string()
|
||||
};
|
||||
@@ -305,7 +305,7 @@ impl CoreManager {
|
||||
let content = match std::fs::read_to_string(config_path) {
|
||||
Ok(content) => content,
|
||||
Err(err) => {
|
||||
let error_msg = format!("Failed to read file: {}", err);
|
||||
let error_msg = format!("Failed to read file: {err}");
|
||||
logging!(error, Type::Config, true, "无法读取文件: {}", error_msg);
|
||||
return Ok((false, error_msg));
|
||||
}
|
||||
@@ -319,7 +319,7 @@ impl CoreManager {
|
||||
}
|
||||
Err(err) => {
|
||||
// 使用标准化的前缀,以便错误处理函数能正确识别
|
||||
let error_msg = format!("YAML syntax error: {}", err);
|
||||
let error_msg = format!("YAML syntax error: {err}");
|
||||
logging!(error, Type::Config, true, "YAML语法错误: {}", error_msg);
|
||||
Ok((false, error_msg))
|
||||
}
|
||||
@@ -331,7 +331,7 @@ impl CoreManager {
|
||||
let content = match std::fs::read_to_string(path) {
|
||||
Ok(content) => content,
|
||||
Err(err) => {
|
||||
let error_msg = format!("Failed to read script file: {}", err);
|
||||
let error_msg = format!("Failed to read script file: {err}");
|
||||
logging!(warn, Type::Config, true, "脚本语法错误: {}", err);
|
||||
//handle::Handle::notice_message("config_validate::script_syntax_error", &error_msg);
|
||||
return Ok((false, error_msg));
|
||||
@@ -364,7 +364,7 @@ impl CoreManager {
|
||||
Ok((true, String::new()))
|
||||
}
|
||||
Err(err) => {
|
||||
let error_msg = format!("Script syntax error: {}", err);
|
||||
let error_msg = format!("Script syntax error: {err}");
|
||||
logging!(warn, Type::Config, true, "脚本语法错误: {}", err);
|
||||
//handle::Handle::notice_message("config_validate::script_syntax_error", &error_msg);
|
||||
Ok((false, error_msg))
|
||||
@@ -449,7 +449,7 @@ impl CoreManager {
|
||||
let mut process_futures = Vec::new();
|
||||
for &target in &target_processes {
|
||||
let process_name = if cfg!(windows) {
|
||||
format!("{}.exe", target)
|
||||
format!("{target}.exe")
|
||||
} else {
|
||||
target.to_string()
|
||||
};
|
||||
@@ -748,7 +748,7 @@ impl CoreManager {
|
||||
let now = Local::now();
|
||||
let timestamp = now.format("%Y%m%d_%H%M%S").to_string();
|
||||
|
||||
let log_path = service_log_dir.join(format!("sidecar_{}.log", timestamp));
|
||||
let log_path = service_log_dir.join(format!("sidecar_{timestamp}.log"));
|
||||
|
||||
let mut log_file = File::create(log_path)?;
|
||||
|
||||
@@ -864,7 +864,7 @@ impl CoreManager {
|
||||
let mut state = service::ServiceState::get();
|
||||
if !state.prefer_sidecar {
|
||||
state.prefer_sidecar = true;
|
||||
state.last_error = Some(format!("通过服务启动核心失败: {}", e));
|
||||
state.last_error = Some(format!("通过服务启动核心失败: {e}"));
|
||||
if let Err(save_err) = state.save() {
|
||||
logging!(
|
||||
error,
|
||||
@@ -1109,7 +1109,7 @@ impl CoreManager {
|
||||
}
|
||||
let core: &str = &clash_core.clone().unwrap();
|
||||
if !IVerge::VALID_CLASH_CORES.contains(&core) {
|
||||
let error_message = format!("Clash core invalid name: {}", core);
|
||||
let error_message = format!("Clash core invalid name: {core}");
|
||||
logging!(error, Type::Core, true, "{}", error_message);
|
||||
return Err(error_message);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user