mirror of
https://github.com/SunBK201/UA3F.git
synced 2025-12-16 08:44:29 +00:00
feat: enhance log timestamp formatting with timezone support
This commit is contained in:
parent
bd61e2c239
commit
b6e43e87f0
@ -6,6 +6,7 @@ import (
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/sunbk201/ua3f/internal/config"
|
||||
@ -24,7 +25,11 @@ func (formatter *uctFormatter) Format(entry *logrus.Entry) ([]byte, error) {
|
||||
} else {
|
||||
b = &bytes.Buffer{}
|
||||
}
|
||||
formatTime := entry.Time.Format("2006-01-02 15:04:05")
|
||||
loc, err := time.LoadLocation("Asia/Shanghai")
|
||||
if err != nil {
|
||||
loc = time.FixedZone("CST", 8*3600)
|
||||
}
|
||||
formatTime := entry.Time.In(loc).Format("2006-01-02 15:04:05")
|
||||
b.WriteString(fmt.Sprintf("[%s][%s]: %s\n", formatTime, strings.ToUpper(entry.Level.String()), entry.Message))
|
||||
return b.Bytes(), nil
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user