chore: only use one log file (close #1116)

This commit is contained in:
JustSong 2024-03-10 23:44:48 +08:00
parent 7e7369dbc4
commit 969042b001

View File

@ -19,9 +19,6 @@ const (
loggerError = "ERR"
)
const maxLogCount = 1000000
var logCount int
var setupLogLock sync.Mutex
var setupLogWorking bool
@ -96,9 +93,7 @@ func logHelper(ctx context.Context, level string, msg string) {
id := ctx.Value(RequestIdKey)
now := time.Now()
_, _ = fmt.Fprintf(writer, "[%s] %v | %s | %s \n", level, now.Format("2006/01/02 - 15:04:05"), id, msg)
logCount++ // we don't need accurate count, so no lock here
if logCount > maxLogCount && !setupLogWorking {
logCount = 0
if !setupLogWorking {
setupLogWorking = true
go func() {
SetupLogger()