5 // (C) 2022 Underground Software
14 #define MAX_LOG_SIZE 10000000 // Maximum size of log file (10 MB)
16 static FILE * log_stream = NULL;
17 static uint32_t logSize = 0;
19 bool InitLog(const char * path)
21 log_stream = fopen(path, "wrt");
23 if (log_stream == NULL)
36 // This logger is used mainly to ensure that text gets written to the log file
37 // even if the program crashes. The performance hit is acceptable in this case!
39 void WriteLog(const char * text, ...)
47 logSize += vfprintf(log_stream, text, arg);
49 if (logSize > MAX_LOG_SIZE)
57 fflush(log_stream); // Make sure that text is written!