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/bootstrap/init.go b/bootstrap/init.go index 2293925..52c2010 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() } diff --git a/prophet.go b/prophet.go index e30e4ba..86a0aac 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{}