feat: refact timezone calling

This commit is contained in:
engigu
2026-02-09 18:39:41 +08:00
parent eb05eafb72
commit f693c32554
10 changed files with 64 additions and 18 deletions
+3 -1
View File
@@ -6,6 +6,7 @@ import (
"path/filepath"
"strings"
"github.com/engigu/baihu-panel/internal/systime"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"gopkg.in/natefinch/lumberjack.v2"
@@ -46,7 +47,8 @@ func (c *customCore) Check(ent zapcore.Entry, ce *zapcore.CheckedEntry) *zapcore
}
func (c *customCore) Write(ent zapcore.Entry, fields []zapcore.Field) error {
timestamp := ent.Time.Format("2006-01-02 15:04:05")
// 统一使用东八区时间
timestamp := systime.InCST(ent.Time).Format("2006-01-02 15:04:05")
level := strings.ToUpper(ent.Level.String())
var levelColor string
+3
View File
@@ -13,6 +13,7 @@ import (
"time"
internalLogger "github.com/engigu/baihu-panel/internal/logger"
"github.com/engigu/baihu-panel/internal/systime"
"github.com/engigu/baihu-panel/internal/utils"
)
@@ -33,6 +34,8 @@ var (
)
func main() {
// 强制设置全局时区为东八区
time.Local = systime.CST
exePath, _ := os.Executable()
exeDir := filepath.Dir(exePath)
os.Chdir(exeDir)