Skip to content

Enhance logging #14

Description

@jbriones1

Description

The only logging we currently have is for tracking connects/disconnects for websockets. We should add some for game events.

We currently have logging for:

  • Server initialization (handlers, port being listened to) in main.go
  • Players registering in player.go: ServeRegister()
  • Administrator registering admin.go: ServeRegister()
  • Socket connects/disconnects socket.go: ServeHTTP/ServeViewer

Events to log

  • Players connecting/reconnecting and the snapshot they receive.
  • AntiPac and FROSH flag being found
  • Players being removed.
  • Failed reads/writes.
  • Failed message sends/receives and who they were being sent to/received from.

Tasks

We can use the library log/slog to handle this. Use INFO, not DEBUG for messages that aren't errors/warnings.

  • Add setter functions for game state fields and add the logging function there.
  • Replace areas where those states are updated (game.state = <value>) to game.SetState(<value>)
    • Appending and removing from lists should have a similar pattern, but state if the item was missing if removal doesn't remove it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions