feat: refact timezone calling
This commit is contained in:
+3
-1
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user