State of the Game #164: Custom Logger

Welcome to another state of the game! This week, I have been hard at work stabilizing the snapshots and adding small features to help keep all builds more stable going forward.

To start the week off, I went back in ‘time’ and made changes to the last stable build to include the memory leak fixes in the build and re-released it. This means the last stable build is actually a bit stable now and people can enjoy playing it without crashes!

After that fix, I moved on to the snapshots and released a small update to the snapshots that addressed the main multiplayer Arena issues. These are :

– Infinite time limit in arena matches
– Instance in which an instant defeat would happen on joining a game
– Instance in which no other players would be visible on the server and no damage could be dealt or received
– Made server not cast a vote in the level selection process

This already made the snapshots much more playable, but I wanted to further increase stability. With that, I created a custom event logger system!

So what is a custom event logger?

Well, the current builds use a default log system in unity. This means, when ever there is an error, or log message, unity writes that message to a file. Simple, but effective, right?

Well, it turns out, that is great if you have a simple game. If you have a really complex game, writing all those log messages can slow everything down.  Also, EVERYTHING gets logged, not just the important stuff. Have you ever searched a 186 MILLION line text file for an error, because I have had to.

Then, there is the cause that unity doesn’t like to close the file, which means when a server is running and dumping every minor message, eventually, it will run out of memory trying to write that file. Also, the file is in a standard location, so if you run 2 copies of M.A.V., they will BOTH be writing to the same file.

So, I tool things into my own hands. I had this really nifty event management system I had created for monitoring stats and achievements and thought this would be a great test bed for it. I then wrote up some custom file handling systems and tapped into unity’s internal log system, and most importantly, turned off unity’s built in log writing.

Now, the logs only contain things that are actually likely to help with debugging a problem in the game. No longer will I have to browser 10 million warnings about audio listeners to find the one game breaking error. The logs can also include any custom debug messages in response to events, allowing a great ‘second tier’ debugging system as well. To top it off, since I am in control of the logging, I can also [in the future] allow players to opt-in to automatically sending log files to a central server, allowing me to see common issues that people have.

So where is this new log file? Well, in the Logs folder in the My Games/BombdogStudios/MAV/ data folder, of course! You didn’t think I had that folder there this whole time without plans to use it, did you? Also, a great new feature to the logs are that they are rolling, so your 10 most recent log files will always be available! This will be very helpful in-case something happens and you couldn’t save the log with the error before restarting M.A.V..

While loggers might not always be the coolest thing to talk about, I feel having better support tools, like the logger, while help the game progress faster, as I spend significantly less time going on goose hunts to try and replicate errors. Also, it should increase the stability of long running servers, which is always a plus!

I will see you next week!

Leave a Reply