diff --git a/src/main.rs b/src/main.rs index 8770193..cda9873 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,8 +6,8 @@ use chrono::Local; use colored::{Color, Colorize}; use fern::Dispatch; use log::Level; -use std::env; use std::path::PathBuf; +use std::{env, fs}; #[tokio::main] async fn main() { @@ -35,7 +35,11 @@ pub fn get_current_dir() -> PathBuf { } pub fn get_log_path() -> PathBuf { - get_current_dir().join("logs") + let path = get_current_dir().join("logs"); + if !path.exists() { + fs::create_dir_all(&path).expect("创建日志目录失败"); + } + path } fn init_log() {