cleaned up some logging

This commit is contained in:
Stephen McQuay 2014-01-23 21:09:27 -08:00
parent d3070ad501
commit c6c45ace51
3 changed files with 11 additions and 8 deletions

View File

@ -125,7 +125,6 @@ func NewGame(id string, width, height float32, obstacles, tick, maxPoints int, m
g.mode.setup(g) g.mode.setup(g)
log.Printf("NewGame: %+v", g)
return g return g
} }

View File

@ -21,8 +21,7 @@ func (p *player) sender() {
} }
} }
p.ws.Close() p.ws.Close()
// TODO log.Printf("%s: robot (%s) sender close", p.Id, p.Robots[0].Id)
log.Printf("player %s: sender close", p.Robots[0].Id)
} }
func (p *player) recv() { 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 // TODO: perhaps we could be a bit more precise in the handling of
// this 'error' by selecting on some kill signal channel and this // this 'error' by selecting on some kill signal channel and this
// json read? // json read?
log.Print("problem receiving JSON from player: ", err) log.Printf("%s: problem receiving JSON from player: %s", p.Id, err)
break 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() p.ws.Close()
} }

View File

@ -204,7 +204,7 @@ func addPlayer(ws *websocket.Conn) {
for { for {
log.Printf("%s Waiting for client to send conf ...", player_id) log.Printf("%s Waiting for client to send conf ...", player_id)
err = websocket.JSON.Receive(ws, &conf) err = websocket.JSON.Receive(ws, &conf)
log.Printf("conf received: %+v", conf) log.Printf("%s: conf received: %+v", player_id, conf)
if err != nil { if err != nil {
log.Printf("%s %s config parse error", gid.Id, player_id) 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}, Heading: v.Vector2d{1, 0},
Scanners: make([]Scanner, 0)} Scanners: make([]Scanner, 0)}
r.Health = r.Stats.Hp r.Health = r.Stats.Hp
log.Printf("Adding Robot: %+v", r) log.Printf("%s: adding robot: %s", p.Id, r.Id)
r.reset(game) r.reset(game)
p.Robots = append(p.Robots, &r) p.Robots = append(p.Robots, &r)
} }
@ -251,7 +251,12 @@ func addPlayer(ws *websocket.Conn) {
}() }()
go p.sender() go p.sender()
p.recv() 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": case "spectator":
s := &Spectator{ s := &Spectator{
send: make(chan Message), send: make(chan Message),