Skip to content

Commit 0eaf13b

Browse files
committed
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.
1 parent acc0fb7 commit 0eaf13b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

AK/Assertions.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,17 @@ extern "C" {
8989

9090
void ak_verification_failed(char const* message)
9191
{
92-
ERRORLN("VERIFICATION FAILED: {}", message);
92+
# if defined(AK_OS_SERENITY) || defined(AK_OS_ANDROID)
93+
bool colorize_output = true;
94+
# else
95+
bool colorize_output = isatty(STDERR_FILENO) == 1;
96+
# endif
97+
98+
if (colorize_output)
99+
ERRORLN("\033[31;1mVERIFICATION FAILED\033[0m: {}", message);
100+
else
101+
ERRORLN("VERIFICATION FAILED: {}", message);
102+
93103
# if defined(EXECINFO_BACKTRACE)
94104
dump_backtrace();
95105
# endif

0 commit comments

Comments
 (0)