What's the best way to handle numerous recurring log entries in game loop?

Posted by Kaa on Game Development See other posts from Game Development or by Kaa
Published on 2014-06-11T04:37:17Z Indexed on 2014/06/11 9:44 UTC
Read the original article Hit count: 148

Filed under:
|

I have a custom logging system, use of which is scattered all over the engine and game. The system is linked to a "LogStore" that has an std::vector<string> logs[NUM_LOG_TYPES] - each vector corresponds with it's log type (info, error, debug, etc.). There's one extra std::vector that has "coordinates" to all log entries in the order they were received.

Now, all the logging output is also displayed inside my development console in the game. The game console is handled by HTML-type GUI and therefore requires a new <p> element being added for each log output.

My problem is that the log entries that are generated in the main loop each frame freeze the engine, because they continue to add elements to the in-game console, and if the console or guy generates a warning - that creates an infinite logging loop.

I want to solve it by handling the recurring log entries in an elegant way that lets you know that something is critically wrong, but won't freeze the engine - like displaying the count of errors in the last 60 frames instead of displaying errors themselves. But how do you guys handle this? Does anyone know any nifty tricks to do this?

I understand the question may sound vague, but if someone came across this type of issue I'm sure they would know exactly what's happening.

Example problematic log entries:

  • OpenGL warnings (I actually do check for errors every frame in many places)
  • Really any prints anywhere in the main loop (may be debugging, may be warnings)

© Game Development or respective owner

Related posts about c++

Related posts about debugging