all repos — mgba @ 3b30aef14b332b3f4ffd5cd077db6dab6e44eef1

mGBA Game Boy Advance Emulator

Test: Flush logs if they get too full
Vicki Pfau vi@endrift.com
Fri, 17 Jul 2020 02:54:47 -0700
commit

3b30aef14b332b3f4ffd5cd077db6dab6e44eef1

parent

f7a6533068ee48c6572c571cf13e4482b0bb8e47

1 files changed, 9 insertions(+), 0 deletions(-)

jump to
M src/platform/test/cinema-main.csrc/platform/test/cinema-main.c

@@ -34,6 +34,7 @@ #include <sys/types.h>

#define MAX_TEST 200 #define MAX_JOBS 128 +#define LOG_THRESHOLD 1000000 static const struct option longOpts[] = { { "base", required_argument, 0, 'b' },

@@ -117,6 +118,8 @@ void CInemaConfigLoad(struct Table* configTree, const char* testName, struct mCore* core);

static void _log(struct mLogger* log, int category, enum mLogLevel level, const char* format, va_list args); +void CIflush(struct StringList* list, FILE* out); + ATTRIBUTE_FORMAT(printf, 2, 3) void CIlog(int minlevel, const char* format, ...) { if (verbosity < minlevel) { return;

@@ -128,6 +131,9 @@ struct StringBuilder* builder = ThreadLocalGetValue(stringBuilder);

if (!builder) { vprintf(format, args); } else { + if (StringListSize(&builder->out) > LOG_THRESHOLD) { + CIflush(&builder->out, stdout); + } vasprintf(StringListAppend(&builder->out), format, args); } #else

@@ -147,6 +153,9 @@ struct StringBuilder* builder = ThreadLocalGetValue(stringBuilder);

if (!builder) { vfprintf(stderr, format, args); } else { + if (StringListSize(&builder->err) > LOG_THRESHOLD) { + CIflush(&builder->err, stderr); + } vasprintf(StringListAppend(&builder->err), format, args); } #else