Added colored logging using ANSI coloring
In src/raylib.h: Added ANSI colors In src/utils.c: strcpy(buffer, "LOG_TYPE: ") -> printf(ANSI_CODE "LOGTYPE: ") In examples/core_custom_logging.c: Change the example to demonstrate using ANSI colors for custom logger
This commit is contained in:
parent
2d7b66dd37
commit
cd3ca0b17a
1 changed files with 29 additions and 13 deletions
14
src/utils.c
14
src/utils.c
|
|
@ -133,15 +133,17 @@ void TraceLog(int logType, const char *text, ...)
|
|||
|
||||
switch (logType)
|
||||
{
|
||||
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, "WARNING: "); break;
|
||||
case LOG_ERROR: strcpy(buffer, "ERROR: "); break;
|
||||
case LOG_FATAL: strcpy(buffer, "FATAL: "); break;
|
||||
case LOG_TRACE: printf(ANSI_BLUE "TRACE: "); break;
|
||||
case LOG_DEBUG: printf(ANSI_CYAN "DEBUG: "); break;
|
||||
case LOG_INFO: printf(ANSI_GREEN "INFO: "); break;
|
||||
case LOG_WARNING: printf(ANSI_YELLOW "WARNING: "); break;
|
||||
case LOG_ERROR: printf(ANSI_RED "ERROR: "); break;
|
||||
case LOG_FATAL: printf(ANSI_BOLD ANSI_RED "FATAL: "); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
printf("%s", ANSI_RESET);
|
||||
|
||||
unsigned int textSize = (unsigned int)strlen(text);
|
||||
memcpy(buffer + strlen(buffer), text, (textSize < (MAX_TRACELOG_MSG_LENGTH - 12))? textSize : (MAX_TRACELOG_MSG_LENGTH - 12));
|
||||
strcat(buffer, "\n");
|
||||
|
|
|
|||
Loading…
Reference in a new issue