2
0
Эх сурвалжийг харах

Adding function to control the "exit-on-error" behaviour.

Marco Lizza 6 жил өмнө
parent
commit
f1d13aa469
2 өөрчлөгдсөн 9 нэмэгдсэн , 1 устгасан
  1. 1 0
      src/raylib.h
  2. 8 1
      src/utils.c

+ 1 - 0
src/raylib.h

@@ -900,6 +900,7 @@ RLAPI Color Fade(Color color, float alpha);                       // Color fade-
 // Misc. functions
 // Misc. functions
 RLAPI void SetConfigFlags(unsigned char flags);                   // Setup window configuration flags (view FLAGS)
 RLAPI void SetConfigFlags(unsigned char flags);                   // Setup window configuration flags (view FLAGS)
 RLAPI void SetTraceLogLevel(TraceLogType logType);                // Set the current threshold (minimum) log level.
 RLAPI void SetTraceLogLevel(TraceLogType logType);                // Set the current threshold (minimum) log level.
+RLAPI void SetTraceLogExit(TraceLogType logType);                 // Set the exit threshold (minimum) log level.
 RLAPI void SetTraceLogCallback(TraceLogCallback callback);        // Set a trace log callback to enable custom logging bypassing raylib's one
 RLAPI void SetTraceLogCallback(TraceLogCallback callback);        // Set a trace log callback to enable custom logging bypassing raylib's one
 RLAPI void TraceLog(TraceLogType logType, const char *text, ...); // Show trace log messages (LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_DEBUG)
 RLAPI void TraceLog(TraceLogType logType, const char *text, ...); // Show trace log messages (LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_DEBUG)
 RLAPI void TakeScreenshot(const char *fileName);                  // Takes a screenshot of current screen (saved a .png)
 RLAPI void TakeScreenshot(const char *fileName);                  // Takes a screenshot of current screen (saved a .png)

+ 8 - 1
src/utils.c

@@ -54,6 +54,7 @@
 
 
 // Log types messages
 // Log types messages
 static TraceLogType logTypeLevel = LOG_INFO;
 static TraceLogType logTypeLevel = LOG_INFO;
+static TraceLogType logTypeExit = LOG_ERROR;
 static TraceLogCallback logCallback = NULL;
 static TraceLogCallback logCallback = NULL;
 
 
 #if defined(PLATFORM_ANDROID)
 #if defined(PLATFORM_ANDROID)
@@ -85,6 +86,12 @@ void SetTraceLogLevel(TraceLogType logType)
     logTypeLevel = logType;
     logTypeLevel = logType;
 }
 }
 
 
+// Set the exit threshold (minimum) log level.
+void SetTraceLogExit(TraceLogType logType)
+{
+    logTypeExit = logType;
+}
+
 // Set a trace log callback to enable custom logging bypassing raylib's one
 // Set a trace log callback to enable custom logging bypassing raylib's one
 void SetTraceLogCallback(TraceLogCallback callback)
 void SetTraceLogCallback(TraceLogCallback callback)
 {
 {
@@ -141,7 +148,7 @@ void TraceLog(TraceLogType logType, const char *text, ...)
 
 
     va_end(args);
     va_end(args);
 
 
-    if (msgType == LOG_ERROR) exit(1);  // If LOG_ERROR message, exit program
+    if (logType >= logTypeExit) exit(1);  // If exit message, exit program
 
 
 #endif  // SUPPORT_TRACELOG
 #endif  // SUPPORT_TRACELOG
 }
 }