//
// Log handler
//
-// by James L. Hammons
-// (c) 2004, 2009 Underground Software
+// by James Hammons
+// (C) 2004, 2014 Underground Software
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// WHO WHEN WHAT
-// --- ---------- ------------------------------------------------------------
+// --- ---------- -----------------------------------------------------------
// JLH 07/23/2009 Added changelog ;-)
//
-#include "types.h"
#include "log.h"
+#include <stdint.h>
-#define MAX_LOG_SIZE 10000000 // Maximum size of log file (10 MB)
+#define MAX_LOG_SIZE 10000000 // Maximum size of log file (10 MB)
-static FILE * log_stream = NULL;
-static uint32 logSize = 0;
+static FILE * logStream = NULL;
+static uint32_t logSize = 0;
bool InitLog(const char * path)
{
- log_stream = fopen(path, "wrt");
+ logStream = fopen(path, "wrt");
- if (log_stream == NULL)
+ if (logStream == NULL)
return false;
return true;
void LogDone(void)
{
- if (log_stream)
- fclose(log_stream);
+ if (logStream)
+ fclose(logStream);
}
//
//
void WriteLog(const char * text, ...)
{
- if (!log_stream)
+ if (!logStream)
return;
va_list arg;
va_start(arg, text);
- logSize += vfprintf(log_stream, text, arg);
+ logSize += vfprintf(logStream, text, arg);
if (logSize > MAX_LOG_SIZE)
{
- fflush(log_stream);
- fclose(log_stream);
+ fflush(logStream);
+ fclose(logStream);
exit(1);
- }//*/
+ }
va_end(arg);
- fflush(log_stream); // Make sure that text is written!
+ fflush(logStream); // Make sure that text is written!
}