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
14 #define MAX_LOG_SIZE 10000000 // Maximum size of log file (10 MB)
16 static FILE * log_stream = NULL;
17 static uint32 logSize = 0;
19 int log_init(char * path)
21 log_stream = fopen(path, "wrt");
23 if (log_stream == NULL)
40 // This logger is used mainly to ensure that text gets written to the log file
41 // even if the program crashes. The performance hit is acceptable in this case!
43 void WriteLog(const char * text, ...)
48 logSize += vfprintf(log_stream, text, arg);
50 if (logSize > MAX_LOG_SIZE)
58 fflush(log_stream); // Make sure that text is written!