Test: Flush logs if they get too full
Vicki Pfau vi@endrift.com
Fri, 17 Jul 2020 02:54:47 -0700
1 files changed,
9 insertions(+),
0 deletions(-)
jump to
M
src/platform/test/cinema-main.c
→
src/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