Published by
Jan 21, 2012 (last update: Jan 22, 2012)

Simple Error Logging

Score: 2.1/5 (28 votes)
*****

About this code

As I was coding my first serious C++ game project (which I am yet to complete), I somehow managed to lose focus.
And that's how this utility came into being: it's the outcome of my brain delaying the engagement with physics, geometry and AI.

Builds with...

This is hybrid C++11/C99 code that uses the header windows.h.
It compiles nicely with MinGW C++ 4.6+, and I prefer using Dev-C++ (Orwell version).
If the project doesn't compile on your Orwell Dev-C++, please check Project Settings, as the project file format is unstable, and be sure the standard is set to ISO C++11.

How to use

You simply call the ERROR_LOG() macro function thing where you want an error message to be issued.
A quaint "OK" message box will appear, and the message will be logged to a file.
The first parameter is the Unit Name, the second parameter is the Error Message, which can be populated like in printf().

Example:
1
2
3
4
void evil(int i)
{
    ERROR_LOG("evil() function", "evil(%d) says: You passed me a %d, and I dislike you.", i, i);
}


Bugs / Missing features

  • Newlines aren't cleared when the error is written to the log file.
  • File operations aren't checked as thoroughly as they should.

Attachments: [Error.zip]