Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
buffge committed Mar 6, 2022
2 parents c3c0971 + cc6c442 commit 963242a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
13 changes: 11 additions & 2 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
}
Expand Down
10 changes: 10 additions & 0 deletions bootstrap/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -120,6 +121,7 @@ func initLog(cfg *conf.LogConf) {
}
func InitApp() error {
admin.MustRunWithAdmin()
initConsole()
initConf()
initLog(&global.Conf.Log)
initLib()
Expand All @@ -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()
}
Expand Down
5 changes: 2 additions & 3 deletions prophet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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{}
Expand Down

0 comments on commit 963242a

Please sign in to comment.