From 4c9a1d9486d9fab4b9c1872ee569b38beadbddb8 Mon Sep 17 00:00:00 2001 From: buffge Date: Sat, 5 Mar 2022 16:50:50 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E5=8F=B0=E5=BF=AB=E9=80=9F=E7=BC=96=E8=BE=91=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E8=BF=9B=E7=A8=8B=E5=8D=A1=E4=BD=8F=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bootstrap/init.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bootstrap/init.go b/bootstrap/init.go index 9a95a33..cbe3dca 100644 --- a/bootstrap/init.go +++ b/bootstrap/init.go @@ -15,6 +15,7 @@ import ( "github.com/pkg/errors" "go.uber.org/zap" "go.uber.org/zap/zapcore" + "golang.org/x/sys/windows" "gopkg.in/natefinch/lumberjack.v2" "gorm.io/driver/sqlite" "gorm.io/gorm" @@ -120,6 +121,7 @@ func initLog(cfg *conf.LogConf) { } func InitApp() error { admin.MustRunWithAdmin() + initConsole() initConf() initLog(&global.Conf.Log) initLib() @@ -128,6 +130,14 @@ func InitApp() error { return nil } +func initConsole() { + stdIn := windows.Handle(os.Stdin.Fd()) + var consoleMode uint32 + _ = windows.GetConsoleMode(stdIn, &consoleMode) + consoleMode = consoleMode&^windows.ENABLE_QUICK_EDIT_MODE | windows.ENABLE_EXTENDED_FLAGS + _ = windows.SetConsoleMode(stdIn, consoleMode) +} + func initGlobal() { go initAutoReloadCalcConf() } From cc6c4423137eadcb59b24e05f6118b78277e40c3 Mon Sep 17 00:00:00 2001 From: buffge <1515888956@qq.com> Date: Mon, 7 Mar 2022 01:46:48 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.go | 13 +++++++++++-- prophet.go | 5 ++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/app.go b/app.go index 70902db..a889092 100644 --- a/app.go +++ b/app.go @@ -7,6 +7,7 @@ import ( "time" "github.com/avast/retry-go" + "github.com/getsentry/sentry-go" "github.com/pkg/errors" "go.uber.org/zap" "golang.org/x/sync/errgroup" @@ -92,7 +93,15 @@ func GetUserScore(summonerID int64) (*lcu.UserScore, error) { return tmpErr }, retry.Delay(time.Millisecond*10), retry.Attempts(5)) if err != nil { - logger.Error("获取游戏对局详细信息失败", zap.Error(err), zap.Int64("id", info.GameId)) + sentry.WithScope(func(scope *sentry.Scope) { + scope.SetLevel(sentry.LevelError) + scope.SetExtra("info", info) + scope.SetExtra("gameID", info.GameId) + scope.SetExtra("error", err.Error()) + scope.SetExtra("errorVerbose", errors.Errorf("%+v", err)) + sentry.CaptureMessage("获取游戏对局详细信息失败") + }) + logger.Debug("获取游戏对局详细信息失败", zap.Error(err), zap.Int64("id", info.GameId)) return nil } mu.Lock() @@ -121,7 +130,7 @@ func GetUserScore(summonerID int64) (*lcu.UserScore, error) { for _, gameSummary := range gameSummaryList { gameScore, err := calcUserGameScore(summonerID, gameSummary) if err != nil { - logger.Error("游戏战绩计算用户得分失败", zap.Error(err), zap.Int64("summonerID", summonerID), + logger.Debug("游戏战绩计算用户得分失败", zap.Error(err), zap.Int64("summonerID", summonerID), zap.Int64("gameID", gameSummary.GameId)) return userScoreInfo, nil } diff --git a/prophet.go b/prophet.go index 84690bf..9feb92b 100644 --- a/prophet.go +++ b/prophet.go @@ -141,7 +141,7 @@ func (p *Prophet) MonitorStart() { p.initLcuClient(port, token) err = p.initGameFlowMonitor(port, token) if err != nil { - logger.Error("游戏流程监视器 err:", err) + logger.Debug("游戏流程监视器 err:", zap.Error(err)) } p.lcuActive = false p.currSummoner = nil @@ -202,7 +202,6 @@ func (p *Prophet) initGameFlowMonitor(port int, authPwd string) error { logger.Debug(fmt.Sprintf("connect to lcu %s", u.String())) c, _, err := dialer.Dial(u.String(), header) if err != nil { - logger.Error("连接到lcu ws 失败", zap.Error(err)) return err } defer c.Close() @@ -226,7 +225,7 @@ func (p *Prophet) initGameFlowMonitor(port int, authPwd string) error { msgType, message, err := c.ReadMessage() if err != nil { // log.Println("read:", err) - logger.Error("lol事件监控读取消息失败", zap.Error(err)) + logger.Debug("lol事件监控读取消息失败", zap.Error(err)) return err } msg := &wsMsg{}