]> Shamusworld >> Repos - virtualjaguar/blobdiff - src/log.cpp
Virtual Jaguar 1.0.4 update (Shamus)
[virtualjaguar] / src / log.cpp
index f748183ab1bfd3af24fd3a43072b9a8341bc1737..173025178d9eef037cc2cc06255e5ef97d06ef3d 100644 (file)
@@ -3,7 +3,7 @@
 //
 // by cal2
 // GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
-// Cleanups by James L. Hammons
+// Cleanups/new stuff by James L. Hammons
 //
 
 #include "log.h"
@@ -13,8 +13,10 @@ FILE * log_stream = NULL;
 int log_init(char * path)
 {
        log_stream = fopen(path, "wrt");
+
        if (log_stream == NULL)
                return 0;
+
        return 1;
 }
 
@@ -27,3 +29,18 @@ void log_done(void)
 {
        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!
+//
+
+void WriteLog(const char * text, ...)
+{
+       va_list arg;
+
+       va_start(arg, text);
+       vfprintf(log_stream, text, arg);
+       va_end(arg);
+       fflush(log_stream);                                     // Make sure that text is written!
+}