diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2025-05-12 18:24:17 +0200 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2025-05-12 18:24:17 +0200 |
| commit | 27685a4680ee9359b48f10687b84adb17c6808ba (patch) | |
| tree | 5c92fa4c64386e3628c3c2ba877d76cb17a0201c /src | |
| parent | 81b26569e55697361fd13e1a951d551b1dbd13a8 (diff) | |
| download | box64-27685a4680ee9359b48f10687b84adb17c6808ba.tar.gz box64-27685a4680ee9359b48f10687b84adb17c6808ba.zip | |
Small improvment on printf_trace utility function
Diffstat (limited to 'src')
| -rw-r--r-- | src/core.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/core.c b/src/core.c index 5422cd39..a855f6ac 100644 --- a/src/core.c +++ b/src/core.c @@ -192,30 +192,33 @@ void openFTrace(int reopen) } } +static void check_ftrace() +{ + int fd = fileno(ftrace); + if(fd<0 || lseek(fd, 0, SEEK_CUR)==(off_t)-1) { + ftrace=fopen(ftrace_name, "a"); + printf_log(LOG_INFO, "%04d|Recreated trace because fd was invalid\n", GetTID()); + } +} void printf_ftrace(int prefix, const char* fmt, ...) { if(ftrace_name) { - int fd = fileno(ftrace); - if(fd<0 || lseek(fd, 0, SEEK_CUR)==(off_t)-1) { - ftrace=fopen(ftrace_name, "a"); - printf_log(LOG_INFO, "%04d|Recreated trace because fd was invalid\n", GetTID()); - } + check_ftrace(); } - va_list args; - va_start(args, fmt); + static const char* names[2] = {"BOX64", "BOX32"}; + if (prefix && ftrace == stdout) { if (prefix > 1) { - fprintf(ftrace, "[\033[31m%s\033[0m] ", - box64_is32bits ? "BOX32" : "BOX64"); + fprintf(ftrace, "[\033[31m%s\033[0m] ", names[box64_is32bits]); } else { - fprintf(ftrace, box64_is32bits ? "[BOX32] " : "[BOX64] "); + fprintf(ftrace, "[%s] ", names[box64_is32bits]); } } + va_list args; + va_start(args, fmt); vfprintf(ftrace, fmt, args); - fflush(ftrace); - va_end(args); } |