|
|
@ -52,8 +52,9 @@ |
|
|
|
// Global Variables Definition |
|
|
|
//---------------------------------------------------------------------------------- |
|
|
|
|
|
|
|
// Log types messages supported flags (bit based) |
|
|
|
static unsigned char logTypeFlags = LOG_INFO | LOG_WARNING | LOG_ERROR; |
|
|
|
// Log types messages |
|
|
|
static int logTypeLevel = LOG_INFO; |
|
|
|
static int logTypeExit = LOG_ERROR; |
|
|
|
static TraceLogCallback logCallback = NULL; |
|
|
|
|
|
|
|
#if defined(PLATFORM_ANDROID) |
|
|
@ -79,10 +80,16 @@ static int android_close(void *cookie); |
|
|
|
// Module Functions Definition - Utilities |
|
|
|
//---------------------------------------------------------------------------------- |
|
|
|
|
|
|
|
// Enable trace log message types (bit flags based) |
|
|
|
void SetTraceLog(unsigned char types) |
|
|
|
// Set the current threshold (minimum) log level. |
|
|
|
void SetTraceLogLevel(int logType) |
|
|
|
{ |
|
|
|
logTypeFlags = types; |
|
|
|
logTypeLevel = logType; |
|
|
|
} |
|
|
|
|
|
|
|
// Set the exit threshold (minimum) log level. |
|
|
|
void SetTraceLogExit(int logType) |
|
|
|
{ |
|
|
|
logTypeExit = logType; |
|
|
|
} |
|
|
|
|
|
|
|
// Set a trace log callback to enable custom logging bypassing raylib's one |
|
|
@ -92,58 +99,56 @@ void SetTraceLogCallback(TraceLogCallback callback) |
|
|
|
} |
|
|
|
|
|
|
|
// Show trace log messages (LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_DEBUG) |
|
|
|
void TraceLog(int msgType, const char *text, ...) |
|
|
|
void TraceLog(int logType, const char *text, ...) |
|
|
|
{ |
|
|
|
#if defined(SUPPORT_TRACELOG) |
|
|
|
char buffer[MAX_TRACELOG_BUFFER_SIZE] = { 0 }; |
|
|
|
if (logType < logTypeLevel) { // Message has level below current threshold, don't emit. |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
va_list args; |
|
|
|
va_start(args, text); |
|
|
|
|
|
|
|
if (logCallback) |
|
|
|
{ |
|
|
|
logCallback(msgType, text, args); |
|
|
|
logCallback(logType, text, args); |
|
|
|
va_end(args); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
switch(msgType) |
|
|
|
{ |
|
|
|
case LOG_INFO: strcpy(buffer, "INFO: "); break; |
|
|
|
case LOG_ERROR: strcpy(buffer, "ERROR: "); break; |
|
|
|
case LOG_WARNING: strcpy(buffer, "WARNING: "); break; |
|
|
|
case LOG_DEBUG: strcpy(buffer, "DEBUG: "); break; |
|
|
|
case LOG_OTHER: strcpy(buffer, "OTHER: "); break; |
|
|
|
default: break; |
|
|
|
} |
|
|
|
|
|
|
|
strcat(buffer, text); |
|
|
|
strcat(buffer, "\n"); |
|
|
|
|
|
|
|
#if defined(PLATFORM_ANDROID) |
|
|
|
switch(msgType) |
|
|
|
switch(logType) |
|
|
|
{ |
|
|
|
case LOG_INFO: if (logTypeFlags & LOG_INFO) __android_log_vprint(ANDROID_LOG_INFO, "raylib", buffer, args); break; |
|
|
|
case LOG_WARNING: if (logTypeFlags & LOG_WARNING) __android_log_vprint(ANDROID_LOG_WARN, "raylib", buffer, args); break; |
|
|
|
case LOG_ERROR: if (logTypeFlags & LOG_ERROR) __android_log_vprint(ANDROID_LOG_ERROR, "raylib", buffer, args); break; |
|
|
|
case LOG_DEBUG: if (logTypeFlags & LOG_DEBUG) __android_log_vprint(ANDROID_LOG_DEBUG, "raylib", buffer, args); break; |
|
|
|
case LOG_OTHER: if (logTypeFlags & LOG_OTHER) __android_log_vprint(ANDROID_LOG_VERBOSE, "raylib", buffer, args); break; |
|
|
|
case LOG_TRACE: __android_log_vprint(ANDROID_LOG_VERBOSE, "raylib", text, args); break; |
|
|
|
case LOG_DEBUG: __android_log_vprint(ANDROID_LOG_DEBUG, "raylib", text, args); break; |
|
|
|
case LOG_INFO: __android_log_vprint(ANDROID_LOG_INFO, "raylib", text, args); ; break; |
|
|
|
case LOG_WARNING: __android_log_vprint(ANDROID_LOG_WARN, "raylib", text, args); break; |
|
|
|
case LOG_ERROR: __android_log_vprint(ANDROID_LOG_ERROR, "raylib", text, args); break; |
|
|
|
case LOG_FATAL: __android_log_vprint(ANDROID_LOG_FATAL, "raylib", text, args); break; |
|
|
|
default: break; |
|
|
|
} |
|
|
|
#else |
|
|
|
switch(msgType) |
|
|
|
char buffer[MAX_TRACELOG_BUFFER_SIZE] = { 0 }; |
|
|
|
|
|
|
|
switch(logType) |
|
|
|
{ |
|
|
|
case LOG_INFO: if (logTypeFlags & LOG_INFO) vprintf(buffer, args); break; |
|
|
|
case LOG_WARNING: if (logTypeFlags & LOG_WARNING) vprintf(buffer, args); break; |
|
|
|
case LOG_ERROR: if (logTypeFlags & LOG_ERROR) vprintf(buffer, args); break; |
|
|
|
case LOG_DEBUG: if (logTypeFlags & LOG_DEBUG) vprintf(buffer, args); break; |
|
|
|
case LOG_OTHER: if (logTypeFlags & LOG_OTHER) vprintf(buffer, args); break; |
|
|
|
case LOG_TRACE: strcpy(buffer, "TRACE: "); break; |
|
|
|
case LOG_DEBUG: strcpy(buffer, "DEBUG: "); break; |
|
|
|
case LOG_INFO: strcpy(buffer, "INFO: "); ; break; |
|
|
|
case LOG_WARNING: strcpy(buffer, "WARN: "); break; |
|
|
|
case LOG_ERROR: strcpy(buffer, "ERROR: "); break; |
|
|
|
case LOG_FATAL: strcpy(buffer, "FATAL: "); break; |
|
|
|
default: break; |
|
|
|
} |
|
|
|
|
|
|
|
strcat(buffer, text); |
|
|
|
strcat(buffer, "\n"); |
|
|
|
vprintf(buffer, args); |
|
|
|
#endif |
|
|
|
|
|
|
|
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 |
|
|
|
} |
|
|
|