4 // Originally by David Raingeard (Cal2)
5 // GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
6 // Cleanups/new stuff by James L. Hammons
15 #define MAX_LOG_SIZE 10000000 // Maximum size of log file (10 MB)
17 static FILE * log_stream = NULL;
18 static uint32 logSize = 0;
20 int LogInit(const char * path)
22 log_stream = fopen(path, "wrt");
24 if (log_stream == NULL)
41 // This logger is used mainly to ensure that text gets written to the log file
42 // even if the program crashes. The performance hit is acceptable in this case!
44 void WriteLog(const char * text, ...)
49 logSize += vfprintf(log_stream, text, arg);
51 if (logSize > MAX_LOG_SIZE)
59 fflush(log_stream); // Make sure that text is written!