less verbose logging

This commit is contained in:
Branden J Brown 2024-02-03 14:26:14 -06:00
parent a8ca8c0d33
commit f1fac2b7e0
1 changed files with 5 additions and 7 deletions

12
game.go
View File

@ -103,7 +103,8 @@ func gameActor(ctx context.Context, g *game.Match, dealer, chall person, join <-
broadcast(ctx, g, dealer, chall, obs)
g.NextGame()
broadcast(ctx, g, dealer, chall, obs)
case game.ErrWrongTurn: // do nothing
case game.ErrWrongTurn:
slog.WarnContext(ctx, "action on wrong turn", "from", a.Player, "action", a.Action)
case errWeirdAction:
slog.WarnContext(ctx, "nonsense action", "from", a.Player, "action", a.Action)
default:
@ -140,7 +141,6 @@ func playerActor(ctx context.Context, p person, actions chan<- action) {
case <-ctx.Done():
return
case actions <- a:
slog.InfoContext(ctx, "action", "action", a)
}
}
}
@ -148,15 +148,13 @@ func playerActor(ctx context.Context, p person, actions chan<- action) {
func broadcast(ctx context.Context, g *game.Match, dealer, chall person, obs []observer) {
// TODO(zeph): this probably should return an error or some other signal
// if a player drops so that the actor knows to quit
slog.InfoContext(ctx, "send to dealer")
if err := wsjson.Write(ctx, dealer.conn, g.DTO(dealer.id)); err != nil {
// TODO(zeph): concede, but we need to be careful not to recurse
slog.InfoContext(ctx, "lost dealer", "player", dealer.id, "err", err.Error())
slog.WarnContext(ctx, "lost dealer", "player", dealer.id, "err", err.Error())
}
slog.InfoContext(ctx, "send to challenger")
if err := wsjson.Write(ctx, chall.conn, g.DTO(chall.id)); err != nil {
// TODO(zeph): concede, but we need to be careful not to recurse
slog.InfoContext(ctx, "lost challenger", "player", chall.id, "err", err.Error())
slog.WarnContext(ctx, "lost challenger", "player", chall.id, "err", err.Error())
}
if len(obs) == 0 {
return
@ -164,7 +162,7 @@ func broadcast(ctx context.Context, g *game.Match, dealer, chall person, obs []o
d := g.DTO(player.ID{})
for _, p := range obs {
if err := wsjson.Write(ctx, p.conn, &d); err != nil {
slog.InfoContext(ctx, "lost observer", "err", err.Error())
slog.WarnContext(ctx, "lost observer", "err", err.Error())
}
}
}