4 // by James L. Hammons
\r
5 // (C) 2006 Underground Software
\r
7 // JLH = James L. Hammons <jlhamm@acm.org>
\r
10 // --- ---------- ------------------------------------------------------------
\r
11 // JLH 01/03/2006 Moved includes out of header file for faster compilation
\r
21 #define MAX_LOG_SIZE 10000000 // Maximum size of log file (10 MB)
\r
23 static FILE * log_stream = NULL;
\r
24 static uint32 logSize = 0;
\r
26 bool InitLog(char * path)
\r
28 log_stream = fopen(path, "wrt");
\r
30 if (log_stream == NULL)
\r
43 // This logger is used mainly to ensure that text gets written to the log file
\r
44 // even if the program crashes. The performance hit is acceptable in this case!
\r
46 void WriteLog(const char * text, ...)
\r
53 va_start(arg, text);
\r
54 logSize += vfprintf(log_stream, text, arg);
\r
56 if (logSize > MAX_LOG_SIZE)
\r
64 fflush(log_stream); // Make sure that text is written!
\r