logog
logger optimized for games
Organizing and filtering log messages by types

Areas of a program such as a game can be broken down into a set of functional areas. Some areas might include AI, audio, graphics, input and the file system.

The logog system allows you to store two dimensions of information with each message that further type the message. These dimensions are referred to as the category and the group of the message. The ultimate meaning of these fields is up to you.

To define the current group for all messages following a certain point in your code, #define the LOGOG_GROUP constant to the name of the group, surrounded by double quotes. Likewise #define the LOGOG_CATEGORY constant to the name of the category surrounded by double quotes.

Your compiler may need the #undef macro to undefine the previous setting of a constant before #define'ing it to something else.

If you wish to set further messages to no specific category or group, #define either LOGOG_CATEGORY or LOGOG_GROUP to NULL as necessary.

/*
The following example produces something like:
.\test.cpp(364) : emergency: {Graphics} [Unrecoverable] The graphics card has been destroyed
.\test.cpp(368) : warning: {Graphics} [Recoverable] The graphics card has been replaced
.\test.cpp(372) : warning: {Audio} [Recoverable] The headphones are unplugged
.\test.cpp(377) : info: Everything's back to normal
*/
{
Cerr err;
#undef LOGOG_GROUP
#undef LOGOG_CATEGORY
#define LOGOG_GROUP "Graphics"
#define LOGOG_CATEGORY "Unrecoverable"
EMERGENCY(_LG("The graphics card has been destroyed"));
#undef LOGOG_CATEGORY
#define LOGOG_CATEGORY "Recoverable"
WARN(_LG("The graphics card has been replaced"));
#undef LOGOG_GROUP
#define LOGOG_GROUP "Audio"
WARN(_LG("The headphones are unplugged"));
#undef LOGOG_CATEGORY
#undef LOGOG_GROUP
#define LOGOG_CATEGORY NULL
#define LOGOG_GROUP NULL
INFO(_LG("Everything's back to... %s!"), _LG("normal"));
}

A Filter can be told to route only messages matching a specified category or group. To do this, call the Filter::Category() or Filter::Group() methods on a specific filter. That filter will then only pass messages matching the criteria you've set.

{
GetFilterDefault().Category(_LG("Unrecoverable"));
Cerr err;
WARN(_LG("Logging messages in the Unrecoverable category..."));
#undef LOGOG_GROUP
#undef LOGOG_CATEGORY
#define LOGOG_GROUP "Graphics"
#define LOGOG_CATEGORY "Unrecoverable"
EMERGENCY(_LG("The graphics card has been destroyed"));
#undef LOGOG_CATEGORY
#define LOGOG_CATEGORY "Recoverable"
WARN(_LG("The graphics card has been replaced"));
#undef LOGOG_GROUP
#define LOGOG_GROUP "Audio"
WARN(_LG("The headphones are unplugged"));
#undef LOGOG_CATEGORY
#undef LOGOG_GROUP
#define LOGOG_CATEGORY NULL
#define LOGOG_GROUP NULL
}