We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Game Logs

In the Peril game, occasionally we want to "log" a game event. Those logs should go to a central location where they can be inspected later. It's common in large backend systems to print logs to stdout or stderr, but to also send logs to a central logging system or database.

Assignment

Whenever "war" events happen, we want to log them. For now, let's just add the functionality to publish them, and we'll let the messages pile up in the logs queue.

      1. If the outcome is that the opponent won, the message should say "{winner} won a war against {loser}".
      2. If the outcome is that the player won, the message should also say "{winner} won a war against {loser}".
      3. If the outcome is a draw, the message should say "A war between {attacker} and {defender} resulted in a draw".

You should be able to verify in the RabbitMQ management UI that a log was published to the game_logs queue.

Run and submit the CLI tests.

You can remove those console.log we added to the subscribeJSON early on in the course.