feat: 添加 env_logger 基础日志系统

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-31 13:41:06 +08:00
parent ec4aae37d9
commit 955396a74d
5 changed files with 11 additions and 1 deletions
+5
View File
@@ -33,6 +33,7 @@ impl Default for AppState {
pub fn new_game(mode: GameMode, config: GameConfig, state: State<AppState>) -> Result<(), String> {
let is_vs_ai = mode == GameMode::VsAi;
let board = Board::new(config.board_size);
log::info!("新游戏: mode={:?}, board_size={}", mode, config.board_size);
*state.board.lock().map_err(|e| e.to_string())? = Some(board);
*state.game_mode.lock().map_err(|e| e.to_string())? = mode;
*state.config.lock().map_err(|e| e.to_string())? = config.clone();
@@ -82,6 +83,10 @@ pub fn place_piece(x: usize, y: usize, state: State<AppState>) -> Result<MoveRes
*state.current_color.lock().map_err(|e| e.to_string())? = color.opponent();
*state.game_over.lock().map_err(|e| e.to_string())? = is_win;
if is_win {
log::info!("游戏结束: 胜者={:?}", color);
}
Ok(MoveResult {
position: pos,
is_win,
+1
View File
@@ -4,6 +4,7 @@ use commands::AppState;
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
log::info!("Tauri 应用初始化完成");
tauri::Builder::default()
.plugin(tauri_plugin_opener::init())
.manage(AppState::default())
+2
View File
@@ -2,5 +2,7 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
fn main() {
env_logger::init();
log::info!("Gobang v2.0 启动");
gobang_gui::run()
}