X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flog.cpp;h=5b2f76317f49b08b1d5433fe37a6a739dc143912;hb=be2fdb272ceeb72d9c50e7d66b58cb73734980f9;hp=282898cc199c0fc090a841e766b8562458e64a13;hpb=67a5f1a40072983cf87ae2093ca95c271d14e706;p=virtualjaguar diff --git a/src/log.cpp b/src/log.cpp index 282898c..5b2f763 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -1,16 +1,23 @@ // // Log handler // -// by cal2 +// Originally by David Raingeard (Cal2) // GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS) // Cleanups/new stuff by James L. Hammons // #include "log.h" -FILE * log_stream = NULL; +#include +#include +#include "types.h" -int log_init(char * path) +#define MAX_LOG_SIZE 10000000 // Maximum size of log file (10 MB) + +static FILE * log_stream = NULL; +static uint32 logSize = 0; + +int LogInit(const char * path) { log_stream = fopen(path, "wrt"); @@ -20,12 +27,12 @@ int log_init(char * path) return 1; } -FILE * log_get(void) +FILE * LogGet(void) { return log_stream; } -void log_done(void) +void LogDone(void) { fclose(log_stream); } @@ -39,7 +46,15 @@ void WriteLog(const char * text, ...) va_list arg; va_start(arg, text); - vfprintf(log_stream, text, arg); + logSize += vfprintf(log_stream, text, arg); + + if (logSize > MAX_LOG_SIZE) + { + fflush(log_stream); + fclose(log_stream); + exit(1); + }//*/ + va_end(arg); fflush(log_stream); // Make sure that text is written! }