14 static const i32 MAX_STACKTRACE_SIZE = 1024;
16 static const char *colors[LOG_LEVEL_MAX] = {
26 KB_ASSERT(color < LOG_LEVEL_MAX,
"color index must not exceed available log levels");
27 fprintf(stdout,
"\033[%sm%s\033[0m", colors[color], msg);
31 KB_ASSERT(color < LOG_LEVEL_MAX,
"color index must not exceed available log levels");
32 fprintf(stderr,
"\033[%sm%s\033[0m", colors[color], msg);
36 void *array[MAX_STACKTRACE_SIZE];
37 i32 size = backtrace(array, MAX_STACKTRACE_SIZE);
38 char **strings = backtrace_symbols(array, size);
39 for (i32 i = 0; i < size; ++i) {
40 fprintf(stdout,
"%3d : %s\n", i, strings[i]);
void platform_print_stacktrace(void)
Print the the call stack of the caller.
void platform_console_write(const char *msg, u8 color)
Write message to the platforms console.
void platform_console_write_error(const char *msg, u8 color)
Write message to the platforms error console.
Interface to access platform specific console printing functionality.
#define KB_ASSERT(expr,...)
Perform runtime assertion and log failures.