diff options
| author | Yang Liu <liuyang22@iscas.ac.cn> | 2025-02-20 22:25:14 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-20 15:25:14 +0100 |
| commit | bb8559933f4e2745b6114e270548301ad081878a (patch) | |
| tree | d064e60293fc6bc303b9d49e7b01298c2af1cb79 /src | |
| parent | c2cb333261e31caedc2cf3ca2a13405c660c30b1 (diff) | |
| download | box64-bb8559933f4e2745b6114e270548301ad081878a.tar.gz box64-bb8559933f4e2745b6114e270548301ad081878a.zip | |
Made error logs prefix has red color (#2396)
Diffstat (limited to 'src')
| -rw-r--r-- | src/core.c | 7 | ||||
| -rw-r--r-- | src/include/debug.h | 6 |
2 files changed, 9 insertions, 4 deletions
diff --git a/src/core.c b/src/core.c index 10d0b11e..51952c7d 100644 --- a/src/core.c +++ b/src/core.c @@ -201,7 +201,12 @@ void printf_ftrace(int prefix, const char* fmt, ...) va_list args; va_start(args, fmt); if (prefix && ftrace == stdout) { - fprintf(ftrace, box64_is32bits ? "[BOX32] " : "[BOX64] "); + if (prefix > 1) { + fprintf(ftrace, "[\033[31m%s\033[0m] ", + box64_is32bits ? "BOX32" : "BOX64"); + } else { + fprintf(ftrace, box64_is32bits ? "[BOX32] " : "[BOX64] "); + } } vfprintf(ftrace, fmt, args); diff --git a/src/include/debug.h b/src/include/debug.h index d5786ae1..631e35d7 100644 --- a/src/include/debug.h +++ b/src/include/debug.h @@ -70,9 +70,9 @@ extern int box64_tcmalloc_minimal; // when using tcmalloc_minimal void printf_ftrace(int prefix, const char* fmt, ...); -#define printf_log_prefix(prefix, L, ...) \ - do { \ - if ((L) <= BOX64ENV(log)) { printf_ftrace(prefix, __VA_ARGS__); } \ +#define printf_log_prefix(prefix, L, ...) \ + do { \ + if ((L) <= BOX64ENV(log)) { printf_ftrace(prefix + (prefix && (L) == LOG_NONE), __VA_ARGS__); } \ } while (0) #define printf_log(L, ...) printf_log_prefix(1, L, __VA_ARGS__) |