From c6c45ace5160be7eb730f1661b4bcf183ecb3f8a Mon Sep 17 00:00:00 2001 From: Stephen McQuay Date: Thu, 23 Jan 2014 21:09:27 -0800 Subject: [PATCH] cleaned up some logging --- game.go | 1 - player.go | 7 +++---- protocol.go | 11 ++++++++--- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/game.go b/game.go index 97e95a6..18f9cbf 100644 --- a/game.go +++ b/game.go @@ -125,7 +125,6 @@ func NewGame(id string, width, height float32, obstacles, tick, maxPoints int, m g.mode.setup(g) - log.Printf("NewGame: %+v", g) return g } diff --git a/player.go b/player.go index cae8751..234d9a2 100644 --- a/player.go +++ b/player.go @@ -21,8 +21,7 @@ func (p *player) sender() { } } p.ws.Close() - // TODO - log.Printf("player %s: sender close", p.Robots[0].Id) + log.Printf("%s: robot (%s) sender close", p.Id, p.Robots[0].Id) } func (p *player) recv() { @@ -36,7 +35,7 @@ func (p *player) recv() { // TODO: perhaps we could be a bit more precise in the handling of // this 'error' by selecting on some kill signal channel and this // json read? - log.Print("problem receiving JSON from player: ", err) + log.Printf("%s: problem receiving JSON from player: %s", p.Id, err) break } @@ -101,6 +100,6 @@ func (p *player) recv() { } } - log.Printf("player %s: recv close", p.Robots[0].Id) + log.Printf("%s: recv close", p.Id) p.ws.Close() } diff --git a/protocol.go b/protocol.go index d6bea26..01569b5 100644 --- a/protocol.go +++ b/protocol.go @@ -204,7 +204,7 @@ func addPlayer(ws *websocket.Conn) { for { log.Printf("%s Waiting for client to send conf ...", player_id) err = websocket.JSON.Receive(ws, &conf) - log.Printf("conf received: %+v", conf) + log.Printf("%s: conf received: %+v", player_id, conf) if err != nil { log.Printf("%s %s config parse error", gid.Id, player_id) @@ -239,7 +239,7 @@ func addPlayer(ws *websocket.Conn) { Heading: v.Vector2d{1, 0}, Scanners: make([]Scanner, 0)} r.Health = r.Stats.Hp - log.Printf("Adding Robot: %+v", r) + log.Printf("%s: adding robot: %s", p.Id, r.Id) r.reset(game) p.Robots = append(p.Robots, &r) } @@ -251,7 +251,12 @@ func addPlayer(ws *websocket.Conn) { }() go p.sender() p.recv() - log.Printf("game %s: player %v has been disconnected from this game\n", gid.Id, p.Robots[0].Id) + log.Printf( + "%s (player): %v (robot) has been disconnected from %s (game)", + p.Id, + p.Robots[0].Id, + gid.Id, + ) case "spectator": s := &Spectator{ send: make(chan Message),