优化日志写入

This commit is contained in:
hahwu 2024-12-18 15:25:39 +08:00
parent 2a4b54f6c6
commit 4b4f101369
2 changed files with 14 additions and 0 deletions

View File

@ -866,5 +866,8 @@ func Destroy() {
G_GameLogicPtr.FriendMgr.SaveData()
G_GameLogicPtr.RankMgr.SaveData()
G_GameLogicPtr.ChampshipMgr.SaveData()
G_GameLogicPtr.MailMgr.SaveData()
G_GameLogicPtr.VarMgr.SaveData()
G_GameLogicPtr.MLogManager.Close()
}
}

View File

@ -47,3 +47,14 @@ func (L *LogMgr) AddLog(logs *Log) {
defer L.Lock.Unlock()
L.L = append(L.L, logs)
}
func (L *LogMgr) Close() {
L.McronSave.Stop()
L.Lock.Lock()
defer L.Lock.Unlock()
for _, v := range L.L {
value, _ := json.Marshal(v)
kafkaMiddleware.SendMsg([]byte(v.EventName), value)
}
L.L = L.L[:0]
}