From 0eaf13bae3b874dd7f7a53e80a08e136ebbdcadb Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Fri, 20 Oct 2023 14:49:38 -0400 Subject: [PATCH] AK: Colorize log message for failed assertions The log message can be hard to spot in a sea of debug messages. Colorize it to make the message more immediately pop out. --- AK/Assertions.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/AK/Assertions.cpp b/AK/Assertions.cpp index 2ab2d3f879..e83daceeb1 100644 --- a/AK/Assertions.cpp +++ b/AK/Assertions.cpp @@ -89,7 +89,17 @@ extern "C" { void ak_verification_failed(char const* message) { - ERRORLN("VERIFICATION FAILED: {}", message); +# if defined(AK_OS_SERENITY) || defined(AK_OS_ANDROID) + bool colorize_output = true; +# else + bool colorize_output = isatty(STDERR_FILENO) == 1; +# endif + + if (colorize_output) + ERRORLN("\033[31;1mVERIFICATION FAILED\033[0m: {}", message); + else + ERRORLN("VERIFICATION FAILED: {}", message); + # if defined(EXECINFO_BACKTRACE) dump_backtrace(); # endif