]> Shamusworld >> Repos - apple2/blobdiff - src/log.cpp
Added Prodos detection for .dsk images, fixes to 80STORE switch.
[apple2] / src / log.cpp
index ebf253544983dfc1499f3a81a66abab48a3b9a01..6994cc5ac1d1649838e7938fdc052e8a0437c4b1 100755 (executable)
@@ -1,10 +1,10 @@
 //
 // Log handler
 //
-// by James L. Hammons
+// by James Hammons
 // (C) 2006 Underground Software
 //
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
 //
 // WHO  WHEN        WHAT
 // ---  ----------  ------------------------------------------------------------
 #include <stdarg.h>
 #include <stdint.h>
 
-#define MAX_LOG_SIZE           10000000                                // Maximum size of log file (10 MB)
+// Maximum size of log file (10 MB ought to be enough for anybody)
+#define MAX_LOG_SIZE           10000000
 
 static FILE * log_stream = NULL;
 static uint32_t logSize = 0;
 
+
 bool InitLog(const char * path)
 {
        log_stream = fopen(path, "wrt");
@@ -33,12 +35,14 @@ bool InitLog(const char * path)
        return true;
 }
 
+
 void LogDone(void)
 {
        if (log_stream)
                fclose(log_stream);
 }
 
+
 //
 // 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!
@@ -52,14 +56,14 @@ void WriteLog(const char * text, ...)
 
        va_start(arg, text);
        logSize += vfprintf(log_stream, text, arg);
+       va_end(arg);
+
+       fflush(log_stream);                                     // Make sure that text is written!
 
        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!
+               log_stream = NULL;
+       }
 }
+