X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flog.cpp;h=623a6b97e187a27c226890ad1d0734b050c0ff40;hb=2fe4f4d3720583b59e0412d2a0cb72109db78573;hp=adf8a18a32cb137752e436e5205fbe0533c2a5f0;hpb=757714edd1100cfbe4dd5c46e4eff480ee25dd3d;p=thunder diff --git a/src/log.cpp b/src/log.cpp index adf8a18..623a6b9 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -1,61 +1,65 @@ // // Log handler // -// by James L. Hammons -// (c) 2004, 2009 Underground Software +// by James Hammons +// (C) 2004, 2014 Underground Software // -// JLH = James L. Hammons +// JLH = James Hammons // // WHO WHEN WHAT -// --- ---------- ------------------------------------------------------------ +// --- ---------- ----------------------------------------------------------- // JLH 07/23/2009 Added changelog ;-) // #include "types.h" #include "log.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 FILE * logStream = NULL; static uint32 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); } + // // This logger is used mainly to ensure that text gets written to the log file // even if the program crashes. The performance hit is acceptable in this case! // 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! } +