less verbose logging
This commit is contained in:
parent
a8ca8c0d33
commit
f1fac2b7e0
12
game.go
12
game.go
@ -103,7 +103,8 @@ func gameActor(ctx context.Context, g *game.Match, dealer, chall person, join <-
|
|||||||
broadcast(ctx, g, dealer, chall, obs)
|
broadcast(ctx, g, dealer, chall, obs)
|
||||||
g.NextGame()
|
g.NextGame()
|
||||||
broadcast(ctx, g, dealer, chall, obs)
|
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:
|
case errWeirdAction:
|
||||||
slog.WarnContext(ctx, "nonsense action", "from", a.Player, "action", a.Action)
|
slog.WarnContext(ctx, "nonsense action", "from", a.Player, "action", a.Action)
|
||||||
default:
|
default:
|
||||||
@ -140,7 +141,6 @@ func playerActor(ctx context.Context, p person, actions chan<- action) {
|
|||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return
|
return
|
||||||
case actions <- a:
|
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) {
|
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
|
// TODO(zeph): this probably should return an error or some other signal
|
||||||
// if a player drops so that the actor knows to quit
|
// 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 {
|
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
|
// 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 {
|
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
|
// 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 {
|
if len(obs) == 0 {
|
||||||
return
|
return
|
||||||
@ -164,7 +162,7 @@ func broadcast(ctx context.Context, g *game.Match, dealer, chall person, obs []o
|
|||||||
d := g.DTO(player.ID{})
|
d := g.DTO(player.ID{})
|
||||||
for _, p := range obs {
|
for _, p := range obs {
|
||||||
if err := wsjson.Write(ctx, p.conn, &d); err != nil {
|
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())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user