static FILE *logFile=NULL; //!< our logfile, where all log-, error- and warning messages are logged
/*!
This functions opens a new logfile named 'lastrun.log' and writes a short header with the date into it.
This should be called as one of the first things. Older files are overwritten.
If 'lastrun.log' couldn't be opened, #logFile is set to \c NULL and calls to #log(), #error() and #warn() will only write on the screen, but not to a file.
*/
void beginLog(){
time_t ltime;
if(logFile!=NULL){
error("(in log::beginLog()): There seems to be another logging session in progress.\n\n");
//endLog();
return;
}
logFile=fopen("lastrun.log", "w+");
if(logFile==NULL){
printf("Couldn't open logFile.\n");
return;
}
log("*************************\n");
log("***** BEGINNING LOG *****\n");
log("*************************\n");
time( <ime );
log("\nTime: %s\n", ctime( <ime ) );
}
/*!
This functions closes #logFile (if it was opened).
Note that calls to #log(), #error() and #warn() are still allowed, but they will only write on the screen.
This function should be called whenever you leave the game and have called #beginLog() before (and then as one of the last things...).
*/
void endLog(){
time_t ltime;
if(logFile==NULL){
error("(in log::endLog()): No logging session in progress.\n\n");
return;
}
log("\n");
log("===================\n");
log("=== CLOSING LOG ===\n");
log("===================\n");
time( <ime );
log("\nTime: %s\n", ctime( <ime ) );
fclose(logFile);
logFile=NULL;
}
/*!
This function prints a message to stdout, #logFile (if opened), the #console (if initialized), #hud::messageBox (if initialized) and updates the #loadingMenu (if initialized and opened). This should be used to indicate some forthcoming to the user, e.g. after something has been loaded etc.
\param formatString a standard \c printf format string
This function prints a warning message to stdout, #logFile (if opened), the #console (if initialized), #hud::messageBox (if initialized) and updates the #loadingMenu (if initialized and opened). This should be used to inform the user of minor errors, that do not have any impact on gameplay but nevertheless are worth noticing (e.g. if an unrecognized token is found in a file).
This is used mainly during debugging.
\param formatString a standard \c printf format string
This function prints an error message to stdout, #logFile (if opened), the #console (if initialized), #hud::messageBox (if initialized) and updates the #loadingMenu (if initialized and opened). This should be used to inform the user of serious errors, that may make the game unplayable, although they aren't a real reason to quit (e.g. if a texture or a model couldn't be loaded).
For really fatal errors, that to not allow the game to proceed, use #fatal().
\param formatString a standard \c printf format string