13 #define MAX_LOG_SIZE 10000000 // Maximum size of log file (10 MB)
15 static FILE * log_stream = NULL;
16 static uint32_t logSize = 0;
18 bool InitLog(const char * path)
20 log_stream = fopen(path, "wrt");
22 if (log_stream == NULL)
35 // This logger is used mainly to ensure that text gets written to the log file
36 // even if the program crashes. The performance hit is acceptable in this case!
38 void WriteLog(const char * text, ...)
46 logSize += vfprintf(log_stream, text, arg);
48 if (logSize > MAX_LOG_SIZE)
56 fflush(log_stream); // Make sure that text is written!