(server) fix:Replace the UTC timezone with Local timezone

This commit is contained in:
CaicukunChiji
2025-07-08 23:04:07 +08:00
parent 6ac00bbfbb
commit 2976c96ed7

View File

@ -2,7 +2,7 @@ use std::fs::{self, OpenOptions};
use std::io::Write;
use std::path::Path;
use chrono::Utc;
use chrono::Local;
use colored::Colorize;
use log::{Level, LevelFilter, Log, Metadata, Record, SetLoggerError};
@ -17,7 +17,7 @@ impl ServerLogger {
fn log_to_console(record: &Record) {
let formatted_message = format!(
"[{}] [{}] [{}:{}]\n{}",
Utc::now().to_rfc3339(),
Local::now().to_rfc3339(),
match record.level() {
Level::Error => "ERROR".red(),
Level::Warn => "WARN".yellow(),
@ -36,7 +36,7 @@ impl ServerLogger {
fn log_to_file(record: &Record) {
let formatted_message = format!(
"[{}] [{}] [{}:{}]\n{}",
Utc::now().to_rfc3339(),
Local::now().to_rfc3339(),
record.level(),
record.file().expect("Failed to get file name!"),
record.line().expect("Failed to get line number!"),