修正不创建日志目录的问题
This commit is contained in:
@@ -6,8 +6,8 @@ use chrono::Local;
|
|||||||
use colored::{Color, Colorize};
|
use colored::{Color, Colorize};
|
||||||
use fern::Dispatch;
|
use fern::Dispatch;
|
||||||
use log::Level;
|
use log::Level;
|
||||||
use std::env;
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
use std::{env, fs};
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
@@ -35,7 +35,11 @@ pub fn get_current_dir() -> PathBuf {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_log_path() -> 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() {
|
fn init_log() {
|
||||||
|
|||||||
Reference in New Issue
Block a user