refactor: 移除冗余日志输出并优化日志处理
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

This commit is contained in:
xinian
2026-02-02 18:32:41 +08:00
parent acc9bcf6ff
commit cdb7cec4ad
17 changed files with 59 additions and 100 deletions

View File

@@ -5,7 +5,6 @@ import (
"blazing/common/socket/errorcode"
"blazing/common/utils"
"blazing/cool"
"blazing/modules/base/service"
"context"
"blazing/logic/service/common"
@@ -18,38 +17,15 @@ import (
"time"
"github.com/alpacahq/alpacadecimal"
"github.com/gogf/gf/v2/os/glog"
"github.com/gogf/gf/v2/util/gconv"
)
var fightpanlog = glog.New()
type MyWriter struct {
logger *glog.Logger
user uint32
}
func (w *MyWriter) Write(p []byte) (n int, err error) {
var (
s = string(p)
//ctx = context.Background()
)
service.NewBaseSysLogService().RecordFight(w.user, s)
return w.logger.Write(p)
}
func init() {
fightpanlog.SetWriter(&MyWriter{
logger: glog.New(),
})
}
func (f *FightC) battleLoop() {
defer func() {
if err := recover(); err != nil { // 恢复 panicerr 为 panic 错误值
// 1. 打印错误信息
var ctx = context.Background()
fightpanlog.Errorf(ctx, "%+v", err)
cool.Logger.Error(ctx, f.ownerID, err)
f.Broadcast(func(ff *input.Input) {
if p, ok := ff.Player.(*player.Player); ok {
head := common.NewTomeeHeader(1001, p.Info.UserID)
@@ -306,10 +282,6 @@ func (f *FightC) resolveRound(p1Action, p2Action action.BattleActionI) {
// handleActiveSwitchAction 处理主动切换精灵动作
func (f *FightC) handleActiveSwitchAction(switchAction *action.ActiveSwitchAction, otherAction action.BattleActionI) {
input := f.GetInputByAction(switchAction, false)
if input.CurrentPet.Info.Hp <= 0 {
input.CurrentPet.Info.Hp = 1
}
if skillAction, ok := otherAction.(*action.SelectSkillAction); ok {
if skillAction.SkillEntity != nil && skillAction.CD != nil {