diff options
author | Maria Matejka <mq@ucw.cz> | 2019-07-10 11:27:08 +0200 |
---|---|---|
committer | Maria Matejka <mq@ucw.cz> | 2019-07-10 11:27:08 +0200 |
commit | b2a4feeb4c877ff56d9b2ebd8119225c53ea40db (patch) | |
tree | db22ae94ddf1208824e9ec70176dce63cb073174 /sysdep/unix | |
parent | eac9250fd5b10809830361b94438339b3b31b270 (diff) | |
parent | 422a9334294dd9a5b13abd8563a3dc7233e64b13 (diff) |
Merge branch 'master' into mq-filter-stack
Diffstat (limited to 'sysdep/unix')
-rw-r--r-- | sysdep/unix/log.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/sysdep/unix/log.c b/sysdep/unix/log.c index c9064834..9d107709 100644 --- a/sysdep/unix/log.c +++ b/sysdep/unix/log.c @@ -309,14 +309,23 @@ die(const char *msg, ...) void debug(const char *msg, ...) { +#define MAX_DEBUG_BUFSIZE 65536 va_list args; - char buf[1024]; + static uint bufsize = 4096; + static char *buf = NULL; + + if (!buf) + buf = mb_alloc(&root_pool, bufsize); va_start(args, msg); if (dbgf) { - if (bvsnprintf(buf, sizeof(buf), msg, args) < 0) - bsprintf(buf + sizeof(buf) - 100, " ... <too long>\n"); + while (bvsnprintf(buf, bufsize, msg, args) < 0) + if (bufsize >= MAX_DEBUG_BUFSIZE) + bug("Extremely long debug output, split it."); + else + buf = mb_realloc(buf, (bufsize *= 2)); + fputs(buf, dbgf); } va_end(args); |