mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
functrace: Output colors only when stdout is a tty
This commit is contained in:
parent
2714bba3f0
commit
0fe3b0dbaf
Notes:
sideshowbarker
2024-07-19 05:45:36 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/0fe3b0dbaf8 Pull-request: https://github.com/SerenityOS/serenity/pull/2528 Reviewed-by: https://github.com/awesomekling
1 changed files with 6 additions and 2 deletions
|
@ -48,6 +48,7 @@
|
|||
#include <unistd.h>
|
||||
|
||||
OwnPtr<DebugSession> g_debug_session;
|
||||
static bool g_should_output_color = false;
|
||||
|
||||
static void handle_sigint(int)
|
||||
{
|
||||
|
@ -70,8 +71,8 @@ void print_syscall(PtraceRegisters& regs, size_t depth)
|
|||
for (size_t i = 0; i < depth; ++i) {
|
||||
printf(" ");
|
||||
}
|
||||
const char* begin_color = "\033[34;1m";
|
||||
const char* end_color = "\033[0m";
|
||||
const char* begin_color = g_should_output_color ? "\033[34;1m" : "";
|
||||
const char* end_color = g_should_output_color ? "\033[0m" : "";
|
||||
printf("=> %sSC_%s(0x%x, 0x%x, 0x%x)%s\n",
|
||||
begin_color,
|
||||
Syscall::to_string(
|
||||
|
@ -115,6 +116,9 @@ int main(int argc, char** argv)
|
|||
return 1;
|
||||
}
|
||||
|
||||
if (isatty(STDOUT_FILENO))
|
||||
g_should_output_color = true;
|
||||
|
||||
const char* command = nullptr;
|
||||
Core::ArgsParser args_parser;
|
||||
args_parser.add_positional_argument(command,
|
||||
|
|
Loading…
Reference in a new issue