Last active
September 15, 2023 18:28
-
-
Save Peter0x44/def2d00145abcf237c6c2f8b6d335852 to your computer and use it in GitHub Desktop.
raylib - colored tracelog output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdarg.h> | |
#include "raylib.h" | |
// Custom logging funtion | |
void LogColored(int msgType, const char *text, va_list args) | |
{ | |
switch (msgType) | |
{ | |
case LOG_INFO: printf("[\e[1;32mINFO\e[0m] : "); break; | |
case LOG_ERROR: printf("[\e[1;31mERROR\e[0m]: "); break; | |
case LOG_WARNING: printf("[\e[1;33mWARN\e[0m] : "); break; | |
case LOG_DEBUG: printf("[DEBUG]: "); break; | |
default: break; | |
} | |
vprintf(text, args); | |
printf("\n"); | |
} | |
int main(void) | |
{ | |
// First thing we do is setting the custom logger to ensure everything raylib logs | |
// will use the custom logger instead of its internal one | |
SetTraceLogCallback(LogColored); | |
TraceLog(LOG_INFO, "info"); | |
TraceLog(LOG_WARNING, "warning"); | |
TraceLog(LOG_ERROR, "error"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment