mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:07:45 +00:00
functrace: Output colors only when stdout is a tty
This commit is contained in:
parent
2714bba3f0
commit
0fe3b0dbaf
1 changed files with 6 additions and 2 deletions
|
@ -48,6 +48,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
OwnPtr<DebugSession> g_debug_session;
|
OwnPtr<DebugSession> g_debug_session;
|
||||||
|
static bool g_should_output_color = false;
|
||||||
|
|
||||||
static void handle_sigint(int)
|
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) {
|
for (size_t i = 0; i < depth; ++i) {
|
||||||
printf(" ");
|
printf(" ");
|
||||||
}
|
}
|
||||||
const char* begin_color = "\033[34;1m";
|
const char* begin_color = g_should_output_color ? "\033[34;1m" : "";
|
||||||
const char* end_color = "\033[0m";
|
const char* end_color = g_should_output_color ? "\033[0m" : "";
|
||||||
printf("=> %sSC_%s(0x%x, 0x%x, 0x%x)%s\n",
|
printf("=> %sSC_%s(0x%x, 0x%x, 0x%x)%s\n",
|
||||||
begin_color,
|
begin_color,
|
||||||
Syscall::to_string(
|
Syscall::to_string(
|
||||||
|
@ -115,6 +116,9 @@ int main(int argc, char** argv)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isatty(STDOUT_FILENO))
|
||||||
|
g_should_output_color = true;
|
||||||
|
|
||||||
const char* command = nullptr;
|
const char* command = nullptr;
|
||||||
Core::ArgsParser args_parser;
|
Core::ArgsParser args_parser;
|
||||||
args_parser.add_positional_argument(command,
|
args_parser.add_positional_argument(command,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue